Skip to content

Instantly share code, notes, and snippets.

@paxperscientiam
Created September 15, 2016 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paxperscientiam/ba9c43e02deb513c85c2aaed37d9e213 to your computer and use it in GitHub Desktop.
Save paxperscientiam/ba9c43e02deb513c85c2aaed37d9e213 to your computer and use it in GitHub Desktop.
Exporting UTF-8 WS Data with VBA
I've posted this on Microsoft Answers and Reddit already, but, for posterity, I'm putting it on Pastebin too.
Refer to this paste: http://pastebin.com/US1wuKgH
Or, to the StackOverflow post by Robert Knight if it still exists: https://stackoverflow.com/questions/6136798/vba-shell-function-in-office-2011-for-mac
Basically, you feed execShell() a script that copies the data from a worksheet and passes it from the clipboard into a newly formed file. The trick, though, is to set the "locale" of the newly spawned shell session.
Example VBA code:
***
rngSomeRange.copy
scriptToRun = "export LC_ALL=en_US.UTF-8 && " & _
"touch " & sOutFolder & "/" & sOutFile & ".tex && " & _
"pbpaste > " & sOutFolder & "/" & sOutFile & ".tex"
execShell scriptToRun, exitCode
****
You'll have to tweak this a bit for your purposes, but holy shit it works!!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment