I have tried to learn something about macros by using the "Record Macro" facility to save some keystrokes or mouse activity and then look at the code to see how it does it. This seems to work for everything I have tried except printing, and I need a macro that will automate some printing.
Imagine I recorded the following:
- simply select a range of cells,
click File->Print,
tick the radio button "selected cells"
press OK.
If I then try to replay the macro, it selects the correct cells but then does nothing. It does not even present the Print dialogue box. Why not? The code, if it helps, that is saved is shown below.
Code: Select all
sub prt
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(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Copies"
args1(0).Value = 1
args1(1).Name = "Collate"
args1(1).Value = true
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args1())
end sub
Thanks
Radagast The Brown