Problem with StarDesktop.loadComponentFromURL

asked 2018-10-10 20:03:37 +0200

dbondo gravatar image

updated 2018-10-10 20:22:36 +0200

Mike Kaganski gravatar image

Ever since Star Office 9 I have been using Macros that have this code or identical ones with the Symbols changed:

Sub OpenDJIA_History
    rem define variables

    Dim Doc As Object
    Dim File As String
    Dim URL As String

    rem get access to the document

    File = "C:\Users\Doug & Dolores\Dropbox\Fund Data\39Wk Avgs\DJIA History"

    URL = ConvertToURL( File + ".ods" ) 

    Doc = StarDesktop.loadComponentFromURL(URL, "_default", 0, Array() )
End Sub

Now all of the sudden when stepping through or running this Macro sub routine I get the following Error Message:

BASIC runtime error.
An exception occurred

Type: com.sun.star.lang.IllegalArgumentExceptionMessage: Unsupported URL 

<file:///C:/Users/Doug%20&%20Dolores/Dropbox/Fund%20Data/39Wk%20Avgs/DJIA%20History.ods>: "type detection failed".

Any idea what has happend or how to correct the "loadComponentFromURL" code?

edit retag flag offensive close merge delete

Comments

What about copy "DJIA History.ods" from DropBox to local hard disk? For example to folder C:\Tests.

JohnSUN gravatar imageJohnSUN ( 2018-10-10 20:47:52 +0200 )edit

That's the way it was years ago at first, but since almost 7-8 years ago I have been using DropBox and it worked perfectly until yesterday when I was trying to copy this sub to a new Macro.

dbondo gravatar imagedbondo ( 2018-10-10 20:53:25 +0200 )edit

FYI - I tried your suggestion with a C:\Test\DJA_History. It worked. Here is the code:

sub OpenDJA_History rem define variables

Dim Doc As Object
Dim File As String
Dim URL As String

rem get access to the document

File = "C:\Test\DJA History"

URL = ConvertToURL( File + ".ods" ) 

Doc = StarDesktop.loadComponentFromURL(URL, "_default", 0, Array() )

End Sub

So my guess is that something has changed in LibreOffice that doesn't like the path to DropBox.

dbondo gravatar imagedbondo ( 2018-10-10 21:26:12 +0200 )edit

Does it work with an & in the filename in Test directory?

Btw: to properly format the code, it should be all indented by additional 4 spaces.

Mike Kaganski gravatar imageMike Kaganski ( 2018-10-10 22:06:51 +0200 )edit

Also: the error is returned from LoadEnv::impl_detectTypeAndFilter() when there's no valid content found; could that be that the file itself is corrupt?

Mike Kaganski gravatar imageMike Kaganski ( 2018-10-10 22:18:22 +0200 )edit