- OpenOffice ClearContents Macro.txt
- (1.2 KiB) Downloaded 134 times
[Solved] Problem editing a macro
[Solved] Problem editing a macro
I know there is probably a simple answer to this, but here goes: I recorded a macro to Clear Content on a spreadsheet. I recorded B2:H14. This works fine, but when I try to add cell B18, it only deletes cell B18. I will appreciate any help. Please see the attachment.
Last edited by Hagar Delest on Fri Jan 11, 2019 9:32 am, edited 1 time in total.
Reason: tagged solved
Reason: tagged solved
OpenOffice 4.1.5
Windows 10 Home 64Bit
Windows 10 Home 64Bit
Re: Problem editing a macro
Try this
The idea is to select the cells with a ToPoint, delete the contents and THEN go to the next location with a second ToPoint and delete there.
Code: Select all
sub ClearContents
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 ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$B$2:$H$14"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Flags"
args2(0).Value = "SVDFN"
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, args2())
args1(0).Name = "ToPoint"
args1(0).Value = "$B$18"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$B$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
end sub
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.