I would like to export a file I have created in UTF-8 CSV using VBA. From searching message boards, I have found the following code that converts a file to UTF-8 (from this thread):
VB:Sub SaveAsUTF8() Dim fsT, tFileToOpen, tFileToSave As String tFileToOpen = InputBox("Enter the name and location of the file to convert" & vbCrLf & "With full path and filename ie. C:\MyFolder\ConvertMe.Txt") tFileToSave = InputBox("Enter the name and location of the file to save" & vbCrLf & "With full path and filename ie. C:\MyFolder\SavedAsUTF8.Txt") tFileToOpenPath = tFileToOpen tFileToSavePath = tFileToSave Set fsT = CreateObject("ADODB.Stream"): 'Create Stream object fsT.Type = 2: 'Specify stream type – we want To save text/string data. fsT.Charset = "utf-8": 'Specify charset For the source text data. fsT.Open: 'Open the stream fsT.LoadFromFile tFileToOpenPath: 'And write the file to the object stream fsT.SaveToFile tFileToSavePath, 2: 'Save the data to the named path End Sub
However, this code only converts a non-UTF-8 file to UTF-8. If I were to save my file in non-UTF-8 and then convert it to UTF-8, it would have already lost all the special characters it contained, thus rendering the process pointless!
What I'm looking to do is save an open file in UTF-8 (CSV). Is there any way of doing this with VBA?
Edit: I have now asked this question on Stack Overflow as well, due to lack of response here.
Last edited by CaptainProg; October 2nd, 2012 at 19:06.
sorry... didnt see your question before now...this might help... http://www.ozgrid.com/forum/showthread.php?t=164547
Check out our new reputation system. Click on the "star" under the post!
There are 10 types of people in the world. Those that understand Binary and those that dont.
Why are Halloween and Christmas the same? Because Oct 31 = Dec 25...
The BEST Lookup function of all time
Dynamic Named Ranges are your bestest friend
There are currently 1 users browsing this thread. (0 members and 1 guests)