Record macro

Creating a macro - Writing a Script - Using the API

Record macro

Postby mitduffy » Sat May 19, 2018 2:43 pm

Objective- Learn how to use “Record Macro”
Plan for practice recording macro
Transfer five digits from one file named “storednumbers”, to a file named “depositnumbers”
Works correctly the first time it is run. Transfers the number from “stored number” to “deposit numbers”

If I then change the original number in the “storednumbers” file and run the macro a second time it does not insert the new number in “depositednumbers” file. Instead the original numbers remain displayed in
“deposited numbers”. Here then the Recorded Macro.

REM ***** BASIC *****

sub macrotest1
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("")

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:OpenFromCalc", "", 0, Array())

rem ----------------------------------------------------------------------
dim args2(0) as new
args2(0).Name = "ToPoint"
args2(0).Value = "$E$3"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())

rem ----------------------------------------------------------------------
dim args4(0) as new
args4(0).Name = "ToPoint"
args4(0).Value = "$C$3"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args4())

end sub

Any help appreciated
Last edited by MrProgrammer on Mon Sep 16, 2019 3:19 am, edited 1 time in total.
Reason: Moved from Beginners forum to Macros and UNO API
Open Office 5.4 on Windows 7
Posts: 2
Joined: Sun May 13, 2018 6:38 pm

Re: Record macro

Postby John_Ha » Sat May 19, 2018 3:28 pm

See the answers to your post in the Macros and UNO API forum.
AOO 4.1.6, Windows 7 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Posts: 6938
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests