I use bookmarks and cross references a lot, but there is a lot of manual steps each time I want to create them.
So I created a macro to automate the steps to create bookmark.
It copies the current selected text, moves back a couple of steps, opens "insert bookmark", paste the copied text, click ok.
The problem is with the "paste" operation - it doesn't paste, it enters the text that I pasted when created the macro.
So I want it do do the ctrl+v operation but it doesn't seem to record that into the macro.
Can I put in some code in the macro to perform the ctrl+v?
Here is the code that was generated for the macro. You can see where it says args4(0).Value = "cooltest" , it hardcodes my test string "cooltest" rather than performing the paste.
Code: Select all
sub create_curr_select_as_bookmark
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Count"
args2(0).Value = 1
args2(1).Name = "Select"
args2(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Count"
args3(0).Value = 1
args3(1).Name = "Select"
args3(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Bookmark"
args4(0).Value = "cooltest"
dispatcher.executeDispatch(document, ".uno:InsertBookmark", "", 0, args4())
end sub