Ask Your Question

I am unable to find methods to delete all hyperlinks and bookmarks in writer from a macro.

asked 2017-10-08 03:45:30 +0100

fixxser gravatar image

I tried recording and using results, but it came back with "Property or method not found: createUnoService." These are the lines I used: doc = StarDesktop.loadComponentFromURL(TargetName, "_blank", 0, Dummy()) dispatcher = doc.createUnoService("") ..... dispatcher.executeDispatch(doc, ".uno:SelectAll", "", 0, Dummy()) dispatcher.executeDispatch(doc, ".uno:RemoveHyperlink", "", 0, Dummy())

I have spent all day looking for resources.

For the best thing would be change "" to "" through the whole document. But I will settle for just erasing the links.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2017-10-09 14:37:34 +0100

fixxser gravatar image

wow, Thanks for the info. I didn't realize all the anchors and such. I am working on such a macro to take care of everything, or as much as I can. One solution I am working on now is to take a portion of what I put into writer, take that portion have it saved as HTML:, filter out all the hyperlink references, then from a browser, just copy and paste into writer. Initial test looks promising. I am investigating using Ubuntu and sed to do the filtering. Thanks for the examples.

edit flag offensive delete link more

answered 2017-10-08 14:33:52 +0100

Lupp gravatar image

updated 2017-10-08 14:35:19 +0100

A (hopefully) complete list of the dispatcher's uno: commands yo find here:
I don't think there is one capable of doing what you want.

You may not be aware of the complexity of the task to find "all hyperlinks" existing in a 'Writer' document. They can be inserted in many different ways, not only concerning your actions, but also the internal representation.

If all your hyperlinks are anchored to TextPortions of the ordinary text, and none to shapes (images e.g.) or to TextPortions inside frames, and ... (donno all the alternatives, probably) ... ,

... you may find a solution enhancing the code contained in the attached demo in Module1. There are also a few hints how to proceed if elements of the DrawPage are concerned. I n addition there is a Module2 containing related code published by Andrew Pitonyak. (Don't feel sure he would still try it this way.) 

Good luck! Be careful. And: If you (hopefully) find a service of the API enumerating all the links, please report here.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-10-08 03:45:30 +0100

Seen: 75 times

Last updated: Oct 09 '17