Problem: Seems it is not possible to create a Macro using “Record Macro” in a file named “Deposited Numbers” to Open another file name “Stored Numbers”. (Want to copy and use data from “Stored Numbers” in “Deposited Numbers”. )
Details:
I am recording a macro in a file named “Deposit Numbers”.
As one of the steps in this macro I proceed to open a file named “Stored Numbers”.
(a source of numbers that will be used in the file “Deposit Numbers”.)
As might be expected, when the “Stored Numbers” file opens the “Deposit Numbers” file containing the macro is set aside, disappears from the screen.
After copying some numbers from the “Stored Numbers “file I need to get back to the “Deposit Numbers” File to complete the macro and access the “Record/Stop Macro” window.
After restoring the appearance of the “Deposit Numbers” file I select “Stop Recording”.
Problem is that when I run the macro it is evident, from the results that the Macro does not open the “Stored Numbers” file.
(Tests show that Saved number changes in “Stored Numbers” file do not appear in follow-up, reruns of the macro)
Here then the Recorded Macro
sub Macro_29
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 = "$F$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$D$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "ToPoint"
args5(0).Value = "$B$2"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args5())
end sub
Appreciate any suggestions