Community,
How can I load a text (*.txt) document with a macro and also specify that I need what is described in the open dialog as "Text Encoded (*.txt)" so that I can specify the desired paragraph markers? If I have the URL of a txt file, this code opens it for me, but I can't specify the paragraphs.
Reference<XComponent> xComponent(xComponentLoader->loadComponentFromURL(tempFileURL,
OUString(RTL_CONSTASCII_USTRINGPARAM( "_blank" )), 0, properties));
I'm sure that a filter must be spelled out in the properties, but I don't know how to get ahold of one.
Thanks.
[Solved] Macro to open txt document as encoded
[Solved] Macro to open txt document as encoded
Last edited by RoryOF on Thu Nov 19, 2015 10:54 am, edited 1 time in total.
Reason: Added [Solved] and green tick [RoryOF, Moderator]
Reason: Added [Solved] and green tick [RoryOF, Moderator]
Apache OpenOffice 4.0.1
Windows, Linux, MacOS
Windows, Linux, MacOS
Re: Macro to open txt document as encoded
Step one is to configure the filter with something like
propertyValuesHelper.add("FilterName", Any(OUSTRING("Text (encoded)")));
However, I will also need some FilterOptions or FilterData and it's being difficult to track down what those values should be.
propertyValuesHelper.add("FilterName", Any(OUSTRING("Text (encoded)")));
However, I will also need some FilterOptions or FilterData and it's being difficult to track down what those values should be.
Apache OpenOffice 4.0.1
Windows, Linux, MacOS
Windows, Linux, MacOS
Re: Macro to open txt document as encoded
Open the file manually specifying the right encoding, locale, delimiter(s), text delimiter, "special numbers", if text should be enforced for quoted strings and with any exceptions to the rules for selected columns. The locale and "special number" optioins are particularly important because it determines how to interprete strings representing decimals, date/times, booleans etc.
Then call the Basic IDE, paste the following snippet to some module below MyMacros.Standard and run it (F5).
It shows an input box from where you can copy the FilterOptions string which was used to open the current document.
Then call the Basic IDE, paste the following snippet to some module below MyMacros.Standard and run it (F5).
It shows an input box from where you can copy the FilterOptions string which was used to open the current document.
Code: Select all
Sub showFilterOptions
Dim args(),i%
args() = thisComponent.getArgs
for i = 0 to uBound(Args())
if args(i).Name = "FilterOptions" then inputbox "","",args(i).value
next
End Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Macro to open txt document as encoded
Wow! That worked like a charm. Thank you very much.
Apache OpenOffice 4.0.1
Windows, Linux, MacOS
Windows, Linux, MacOS
Re: [Solved] Macro to open txt document as encoded
Values I receive look like
"MS_1252,CR,Times New Roman,en-US,"
but unfortunately there is no hint about how a font size can be set. On import of text the font size seems to default to 10pt which is too small for me and not one of any preset defaults that I can find. Does anyone know how font size can be set on import? Alternatively, can some global default be set that will apply to the text. A style "Preformatted Text" is created with font size of 10pt specified, but I can't find where that comes from or how to influence it.
"MS_1252,CR,Times New Roman,en-US,"
but unfortunately there is no hint about how a font size can be set. On import of text the font size seems to default to 10pt which is too small for me and not one of any preset defaults that I can find. Does anyone know how font size can be set on import? Alternatively, can some global default be set that will apply to the text. A style "Preformatted Text" is created with font size of 10pt specified, but I can't find where that comes from or how to influence it.
Apache OpenOffice 4.0.1
Windows, Linux, MacOS
Windows, Linux, MacOS
Re: [Solved] Macro to open txt document as encoded
Get StyleFamily "CellStyles", change the properties of style "Default". I would simply increase the zoom factor.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice