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 line input #file_number, string_variable
In order to be imported correctly, my text file has to be interpreted as ANSI encoded.
However Libre Office seems to interpret it as UTF-8 encoded.
This causes certain special characters (e.g. ä, ß …) to be incorrectly displayed as some strange (?) symbol.
How can i make Libre Office interpret my text file as ANSI encoded?
I realise that i have to use code that looks somewhat like this:
Dim MyDoc As Object Dim props(1) As New com.sun.star.beans.PropertyValue Dim File_Number As Integer Dim String_Variable As String props(0).Name = "FilterName" props(0).Value = "Text - txt - csv (StarCalc)" props(1).Name = "FilterOptions" props(1).Value = "44,34,76,1,,1031,true,true" MyDoc = StarDesktop.LoadComponentFromURL(ConvertToURL("file_name.txt"), "_blank", 0, props() ) FileNo = FreeFile Open Mydoc For Input As File_Number Line Input #File_Number, String_Variable
Unfortunately this codes fails at “Open Mydoc For Input As File_Number”. The error Message is: “BASIC runtime error. Object variable not set”