Hi,
I try to make a macro to ease the transfer of a document in the OpenOffice
text document that requires 9 steps in the "manual" way. I recorded a macro,
but it works only in that document where it was created. How can I write a
macro that changes a text page from Portrait to Landscape (and vice versa) in
any text document?
The recorded macro reads:
sub ToLandscape
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 = "DesignerDialog"
'args1(0).Value = true
'dispatcher.executeDispatch(document, ".uno:DesignerDialog", "", 0, args1())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:NewStyle", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Template"
args3(0).Value = "To Landscape"
args3(1).Name = "Family"
args3(1).Value = 8
dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args3())
rem ----------------------------------------------------------------------
'dim args4(0) as new com.sun.star.beans.PropertyValue
'args4(0).Name = "DesignerDialog"
'args4(0).Value = false
'dispatcher.executeDispatch(document, ".uno:DesignerDialog", "", 0, args4())
end sub
I think the problem lies in the line args3(0).Value = "To Landscape" because
when I recorded the macro I had to give a new name in the DesignerDialog each
time I recorded a new macro in a new text document. I also tried to delete
the name so the line read args3(0).Value = "" but the macro didn't work. I
then recorded the simple macro sub Test1 below, and it works in any text
document, so some macros are more "universal" than others.
sub Test1
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 = "Text"
args1(0).Value = "test"
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args1())
end sub
Thankful for answerfor how to get around the problem in macro sub ToLandscape
Best Regards,
Mikael Epstein
username mikael123 in openoffice.org/contact.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]