opening file via macro failes

Hi,
I can't find any information on how to set the arguments for
"LoadComponentFromURL" when loading a csv-file via macro over the network.
The example below worked fine with OpenOffice some time ago, but yields
exceptions when running it with LibreOffice because the function call
returns a NULL pointer. So my question:

- where can I find a list of valid filters for LibreOffice?
- what arguments do I have to provide to read csv-files?

The available documentation in the API on how to supply these arguments is
useless when it doesn't provide the allowed values or a hint how to
construct them. Also I couldn't find any helpful information via Google.

BR
HP

Hi :slight_smile:
Sorry i can't help with Macros and sorry no-one else has been able to
reply yet! The best i can do is to point to documentation and hope
something in there helps. First Chapter 13 of the "Getting Started"
guide
https://wiki.documentfoundation.org/Documentation/Publications
Then Andrew Pitonyak's guide
https://wiki.documentfoundation.org/Documentation/Other_Documentation_and_Resources#Programmers

Regards from
Tom :slight_smile:

Hi HP

So first of all I tried your macro with the LibreOffice 4.2.0 and did not experience any problems, once I set up a valid url of course. I used the following code.

Sub TryToOpenCsvFromTheInternet
    Dim loadArgs2(1) as New com.sun.star.beans.PropertyValue

    lurl = "http://download.finance.yahoo.com/d/quotes.csv?s=%40^DJI,GOOG&f=nsl1op&e=.csv"
    lsfo = "44/32,34,ANSI,2,"

    loadArgs2(0).Name = "FilterName"
    loadArgs2(0).Value = "Text - txt - csv (StarCalc)"
    loadArgs2(1).Name = "FilterOptions"
    loadArgs2(1).Value = lsfo

    lDoc = StarDesktop.LoadComponentFromURL(lurl,"_blank",0,loadArgs2())
    lSheet = lDoc.Sheets().getByIndex(0)
End Sub

When it comes to the documentation of the filter options this is probably as close as you get:
https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options#Filter_Options_for_the_CSV_Filter

There is also a simple and effective way to find out different options, as described by Villeroy [1]

<quote>
Open the csv manually with all bells and whistles. Then run the following code and copy the FilterOptions.

Sub showFilterOptions()

Dim args(),i%
    args() = ThisComponent.getArgs()
    for i = 0 to uBound(Args())
       if args(i).Name = "FilterOptions" then inputbox args(i).Name,"",cStr(args(i).value)
    next
End Sub|
<end of quote>

[1] http://140.211.11.67/en/forum/viewtopic.php?t=58105&p=256500#p256500

Med vänlig hälsning
Niklas Johansson

HP4 skrev 2014-02-25 16:57:

Download AndrewBase.odt

Listing 41 (ShowFlatDriverArgs) will display the supported arguments. In fact, just before the listing, there is a button that you can click in the document that will run the macro and display the arguments for you.

The macro may be structured such that the file must exist on disk because it calls methods like GetSourceCodeDir and LoadDBLibs. Check it out and let us know if you are not able to run it.

I have not looked at this in a few years, so my memory is a bit vague, but, it should help....

http://www.pitonyak.org/database/AndrewBase.odt

Hi all,

thank for your help and suggestions. In the meantime I've updated to version
the newest version 4.1.5.3 of LibreOffice on Windows 8.1/64Bit.
The original error (immediate NULL-pointer result) in the old envoronment
(Version 3.6) disappeared, but I'm still not able to get stable results.

When I try the suggested url

"http://download.finance.yahoo.com/d/quotes.csv?s=%40^DJI,GOOG&
f=nsl1op&e=.csv"

sometimes it will be successful after 1-2 minutes, sometimes it will timeout
and return NULL-pointer.

With another url

"http://ichart.yahoo.com/table.csv?s=^GDAXI&
a=3&b=3&c=2012&d=1&e=28&f=2014&g=d&ignore=.csv"

I also observed freezes of LibreOffice (at least after 10 minutes I decided
to kill the process).

In all cases entering the url into firefox will always immediately response
with opening the data in EXCEL without any delay.

Does anybody know about special problems with Windows 8.1 especially when
running in 64bit-environment??

BR
Hans-Peter