Ask Your Question

Macro to break external link in text document

asked 2021-04-07 22:18:28 +0200

Olivier gravatar image

I have a text document that has Sections with links to external text files.

I need to break these links to that the document stays independent of the external sources.

I can get the sections with, e.g.

oSec = ThisComponent.getTextSections().getByName("SEC_GUIDE")

But then I can't find a way to break the external link.


oSec.FileLink.FileURL = ""
oSec.FileLink.FilterName = ""

is ineffective to break the link.

Note that with the dialog Format - Sections, I can clear the Link checkbox and I'm done. Less trivial is to do that with a macro.

Note2: I can also break the link with Edit - Links . But don't know how to get the collection of external links...

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2021-04-08 19:46:30 +0200

Try this:

l = new
oSec.FileLink = l
edit flag offensive delete link more


Effectively the file link is then broken as demanded. But it also makes the linked contents disappear. My strategy was to break the link and keep the contents.

Olivier gravatar imageOlivier ( 2021-04-08 22:20:27 +0200 )edit

It is kept here in a sample lorem ipsum file using Version: (x64) / LibreOffice Community Build ID: 8a45595d069ef5570103caea1b71cc9d82b2aae4 CPU threads: 12; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win Locale: ru-RU (ru_RU); UI: en-US Calc: CL

But indeed I might overlook something.

Mike Kaganski gravatar imageMike Kaganski ( 2021-04-09 08:22:22 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2021-04-07 22:18:28 +0200

Seen: 24 times

Last updated: Apr 08