[Solved] Invalid URL (Concatenated Strings)

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
sokolowitzky
Posts: 103
Joined: Mon Sep 15, 2014 7:34 pm

[Solved] Invalid URL (Concatenated Strings)

Post by sokolowitzky »

Hello there,

I have bunch of file names on a column in calc. I have created files with names of many of them. But for the ones that I have not created a file yet, I want the macro to create a file during the process.
The code I have made is here below. I don't understand what is wrong with it. The system says "Url seems to be an unsupported one"
I have looked for some other topics about unsupported url, but no joy, it seems like my case is a bit more amateurish. And could not find a useful solution. anyone with an idea?

Code: Select all

SUB IFITAS
DIM CELL1 AS OBJECT
DIM URLS AS STRING
CELL=THISCOMPONENT.SHEETS(0).GETCELLRANGEBYNAME("H2")
elementURL1 ="file:///C:/Users/Sokolowitzky/Desktop/3072NAMEb/" + CELL1.STRING + ".ods"
IF ISMISSING(elementURL1) THEN
elementURL1 = "private:factory/scalc"
ELSE elementURL1 ="file:///C:/Users/Sokolowitzky/Desktop/3072NAMEb/" + CELL1.STRING + ".ods"
END IF
 elementDoc = starDeskTop.loadComponentFromURL ( elementURL1 , "_blank", 0, array())
'elementDoc.CurrentController.Frame.ContainerWindow.setVisible(False)
omainsheet=elementDoc.sheets(0)
IF NOT ISMISSING(elementURL1) THEN
elementDoc.store(TRUE)
else sSaveToURL1 = elementURL1
elementDoc.storeASUrl(sSaveToURL1, Array())
END IF
END SUB
Last edited by sokolowitzky on Fri Nov 09, 2018 4:49 am, edited 1 time in total.
Win10-OpenOffice 4.1/LibreOffice 7.4
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Invalid URL (Concatanated Strings)

Post by Zizi64 »

CELL or CELL1 ???
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Invalid URL (Concatanated Strings)

Post by RoryOF »

Insert a msgbox into your code to display what it has worked out the URL to be. As soon as you see that you should know what's wrong.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
sokolowitzky
Posts: 103
Joined: Mon Sep 15, 2014 7:34 pm

Re: Invalid URL (Concatanated Strings)

Post by sokolowitzky »

@Zizi, I was just modifying to see what is wrong. I have forgot changing it. Anyway, this issue does not seem to be related with it.
Here is the code.
@RoryOf It says "type detection failed". I don't understand what this means.

Code: Select all

DIM CELL1 AS OBJECT
DIM URLS AS STRING
DIM eURL1 AS STRING
DIM CELE AS STRING
DIM DOC1 AS OBJECT
DIM SHEET1 AS OBJECT
DOC1 = THISCOMPONENT
SHEET1 = DOC1.SHEETS(0)
CELL1=SHEET1.GETCELLRANGEBYNAME("H2")
CELE = CELL1.STRING
MSGBOX CELE
eURL1 ="file:///C:/Users/SokolowitzkyDesktop/NAMEB/" + CELE + ".ods"
MSGBOX eURL1
IF ISMISSING(eURL1) THEN
eURL1 = "private:factory/scalc"
elementDoc = starDeskTop.loadComponentFromURL ( eURL1 , "_blank", 0, array())
ELSE eURL1 ="file:///C:/Users/Sokolowitzky/Desktop/NAMEB/" + CELE + ".ods"
END IF
 elementDoc = starDeskTop.loadComponentFromURL ( eURL1 , "_blank", 0, array())
'elementDoc.CurrentController.Frame.ContainerWindow.setVisible(False)
omainsheet=elementDoc.sheets(0)
IF NOT ISMISSING(eURL1) THEN
elementDoc.store(TRUE)
else sSaveToURL1 = eURL1
elementDoc.storeASUrl(sSaveToURL1, Array())
END IF
END SUB
Win10-OpenOffice 4.1/LibreOffice 7.4
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Invalid URL (Concatanated Strings)

Post by RoryOF »

You need to see the URL it builds, not its error message.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
sokolowitzky
Posts: 103
Joined: Mon Sep 15, 2014 7:34 pm

Re: Invalid URL (Concatanated Strings)

Post by sokolowitzky »

It seems like If ismissing(url) part does not work. Because even though there is no file with this name, it gives error in the "ELSE" part of if condition.
Here is the url it shows. URL seems tecnically valid to me. If condition should check and seeing it is missing, should create a blanksheet.
Attachments
scr.PNG
scr.PNG (9.63 KiB) Viewed 2042 times
Win10-OpenOffice 4.1/LibreOffice 7.4
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Invalid URL (Concatanated Strings)

Post by Zizi64 »

I think you need the

Code: Select all

If FileExists(sFileName)=FALSE
statement instead of the ISMISSING...
The ISMISSING is for examine the optional passed parameters in a sub/function.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
sokolowitzky
Posts: 103
Joined: Mon Sep 15, 2014 7:34 pm

Re: Invalid URL (Concatanated Strings)

Post by sokolowitzky »

thank you. I was so close to figure out that I was using a wrong statement, and you show it.
Win10-OpenOffice 4.1/LibreOffice 7.4
Post Reply