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

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(“com.sun.star.frame.DispatchHelper”)

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 “blackholes.com” to “whiteholes.net” through the whole document. But I will settle for just erasing the links.

A (hopefully) complete list of the dispatcher’s uno: commands yo find here:
https://wiki.documentfoundation.org/Development/DispatchCommands#Dispatch_commands_by_tools
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.

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.