Ask Your Question

Programmatically change and update link to external data

asked 2017-01-22 22:28:27 +0200

thoni56 gravatar image

I want to write a macro that updates a sheets link to external data. The data is a table in an HTML-file.

I've looked at Document.SheetLink but it seems there is no actual link there altough there is one entry, and I can't seem to write to that.

I've also tried Sheet.Link(url, sheet, filter, filter_options, mode) and it seems that updates some type of link because if the URL is incorrect Calc displays "Link could not be updated" and shows the incorrect link. But if the link is correct nothing changes.

I'm doing this in LibreOffice Basic.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-01-23 09:14:00 +0200

thoni56 gravatar image

I was on Windows (if that matters) and it seems that a correct URL to a file needs to start with file:///C:/path/to/file. Note the three slashes after the colon.

What threw me off was that if you do, "sheetname", "", "",

which seems correct according to the API documentation, for an HTML-file the "sheetname" will not work even if that is one of the tables prompted when you do Sheet->Link to external data.

Probably this can only be used if you link another Calc-sheet, although I'm guessing here.

So three slashes in the URL and an empty string as the sheet name in Sheet.Link() works like I want it to.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-01-22 22:28:27 +0200

Seen: 505 times

Last updated: Jan 23 '17