Record macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Locked
mitduffy
Posts: 2
Joined: Sun May 13, 2018 6:38 pm

Record macro

Post by mitduffy »

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”
Problem:
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("com.sun.star.frame.DispatchHelper")

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

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
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 com.sun.star.beans.PropertyValue
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
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Record macro

Post by John_Ha »

See the answers to your post in the Macros and UNO API forum.
LO 6.4.4.2, Windows 10 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.
Locked