Hello Officers!
I’m in desperate need of your help. Since yesterday I try to code a Find and Replace macro (+ Regular Expressions) with Python.
I want to find “.+” and replace it with “&”.
That’s what I have up to now:
def search():
document = XSCRIPTCONTEXT.getDocument()
ctx = uno.getComponentContext()
sm = ctx.ServiceManager
dispatcher = sm.createInstanceWithContext("com.sun.star.frame.DispatchHelper", ctx)
sheet = document.Sheets.getByIndex(0)
replace = sheet.createReplaceDescriptor()
replace.SearchRegularExpression = True
replace.SearchString = ".+"
replace.ReplaceString ="&"
return None
Unfortunately, it happens absolutely nothing.
I’m happy and thankful for every little hint, code example and idea.