So basically, my boss would like a spreadsheet automated. I’m already familiar with several other programming languages and I did use Visual Basic 6.0 way, way, way back in the day, so this doesn’t look too unfamiliar. However, when I tried to record a macro, I developed two possible issues.
1.) The code did not work (I modified it slightly)
2.) The note behind record macros says “may be limited”
sub copy
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 = "$H$10:$H$12"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "CopyToHere"
args2(0).Name = "$J$10:$J$12"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
end sub
When I executed this, from the recording, I copied the values from H10:H12 to J10:J12. However, by default, there was no mention of of the destination in the macro. While this asks for copy confirmation, it does not seem to copy anything.
Can anyone tell me any of:
1.) Where does the com.sun.star sequence come from?
2.) What does the 0 in parenthesis mean behind Args1?
I added all the lines that involve the term “args2”, but it didn’t help move the cursor or anything.
Thanks a lot!