[Solved] Updating external link data

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
gurkand
Posts: 29
Joined: Wed Feb 28, 2018 10:27 am

[Solved] Updating external link data

Post by gurkand »

Hi All,
My Calc workbook has links to external data and after "Enabling" these connections, some of them fail to update. When I notice the failed ones, I have to update that specific one manually.
How can I do this within the script (LibreOffice Basic) that I am already running for manipulating the data afterwards?
ie. if Cell is "" Then <reload/update that specific link>
Is there a command that I can use in this kind of a logic?
Thanks in advance.
Last edited by gurkand on Fri Sep 13, 2019 7:14 pm, edited 1 time in total.
LibreOffice 6.3
JeJe
Volunteer
Posts: 2783
Joined: Wed Mar 09, 2016 2:40 pm

Re: Updating external link data

Post by JeJe »

macro for updating all links here:

viewtopic.php?f=20&t=6004#p28037
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
gurkand
Posts: 29
Joined: Wed Feb 28, 2018 10:27 am

Re: Updating external link data

Post by gurkand »

Hello All,

I am trying to update the 4th link as seen in the list of links.jpg.

The macro I wrote for this, and the error message when I try to run are also attached as the error message.jpg.

Any help for this, please?

Thanks in advance.
Attachments
error message.jpg
error message.jpg (38.35 KiB) Viewed 3418 times
list of links.jpg
LibreOffice 6.3
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Updating external link data

Post by UnklDonald418 »

Since the error message indicates there are fewer than 5 links on your spreadsheet, try adding 2 lines to help with debugging.
Immediately after defining oDocument add

Code: Select all

print oDocument.Title
print oDocument.SheetLinks.Count
The first to verify that oDocument is referring to the correct document.
The second to determine how many links the document supposedly has.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Updating external link data

Post by Villeroy »

The html links in the screen shot aren't SheetLinks. These are AreaLinks.
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
gurkand
Posts: 29
Joined: Wed Feb 28, 2018 10:27 am

Re: Updating external link data

Post by gurkand »

Many thanks for your help.

It is working now.

If you could tell me where I can I find the options that are avail like AreaLinks / getbyIndex() / refresh() I will appreciate that.
LibreOffice 6.3
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Updating external link data

Post by Villeroy »

In the API documentation and with the help of MRI or any other object inspector.
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
JeJe
Volunteer
Posts: 2783
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Updating external link data

Post by JeJe »

What I do is type in OpenOffice plus the search word into a search engine.

OpenOffice AreaLinks second result is this page which has the relevent links to the OpenOffice API reference:

https://wiki.openoffice.org/wiki/Docume ... Area_Links

You'll often find someone has had the problem before and there'll be a thread like this one - which you can also find in the search box at the top of the page.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply