porthaa.blogg.se

Change text encoding mac
Change text encoding mac







Unfortunately I do not want the user to see a new window appear and i want the code to have high performance. The encoding is interpreted correctly - yay! When the MyDoc = StarDesktop.LoadComponentFromURL is executed a new LibreOffice Window shows up displaying the contents of the imported file. MyDoc = StarDesktop.LoadComponentFromURL("file:////", "_blank", 0, props() ) The improved - but still buggy - code is: Dim MyDoc As Object For some reason i need to provide the complete path to the file for the StarDekstop.loadComponentFromURL to work, although the text file lies in the same folder as the file running the macro.

change text encoding mac

"FIX,34,1,1,483647/9,1031,false,false"įurther on i found one reason why my code didn’t run. This results in a window popping up that shows the FilterOptions i have to use in my macro to get the same results. If args(i).Name = "FilterOptions" then inputbox "","",args(i).value Then i ran this code i found on the internet on the imported file: Sub showFilterOptions I determined the FilterOptions i need for my text file by manually opening it and choosing the needed import settings trough the GUI. tInputStream(oUcb.OpenFileRead(sPath))įind the strings for the encoding in column 2 in Character Sets OInputStream = createUnoService(".TextInputStream") OUcb = createUnoService(".SimpleFileAccess") OFileDialog = CreateUnoService(".dialogs.FilePicker")Īnd then for to read the lines sub LineRead_Win1252ĭim oUcb as variant 'for If your source is not a csv file, but you only want to read a file line by line, then you can use these macros.įor to get the path to the file: Function GetPath as string You need to know the encoding exactly to get the correct number from the table “Character set”. For the meaning of the parameters see Filter Options - Apache OpenOffice Wiki. There is a macro in Calc: open and save csv-file with given filter options only a line dim oDlg as variant is missing there. The error Message is: “BASIC runtime error. Unfortunately this codes fails at “Open Mydoc For Input As File_Number”. MyDoc = StarDesktop.LoadComponentFromURL(ConvertToURL("file_name.txt"), "_blank", 0, props() ) Props(0).Value = "Text - txt - csv (StarCalc)" I realise that i have to use code that looks somewhat like this: Dim MyDoc As Objectĭim props(1) As New .PropertyValue

change text encoding mac

How can i make Libre Office interpret my text file as ANSI encoded?

change text encoding mac

ä, ß …) to be incorrectly displayed as some strange (?) symbol. This causes certain special characters (e.g.

change text encoding mac

However Libre Office seems to interpret it as UTF-8 encoded. In order to be imported correctly, my text file has to be interpreted as ANSI encoded. I have written a macro that reads line after line of a text file into a string variable: open file_name for input as file_number









Change text encoding mac