Ask Your Question

How to apply a paper tray to ALL page styles? [closed]

asked 2016-11-28 12:23:47 +0100

Coro gravatar image

updated 2020-09-16 10:09:47 +0100

Alex Kemp gravatar image

For any given pre existing document (of which there are literally hundreds of thousands) I need to create a macro that will print the first page on paper from Tray 2 and all subsequent pages from Tray 1. Is there a simple way of doing this?

So far the only way I can find is to change the paper tray settings in the various page styles. This approach is no good however because for any given document I do not know which page styles will be applied within.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2020-09-16 10:09:39.992243

3 Answers

Sort by » oldest newest most voted

answered 2016-12-01 18:17:17 +0100

Coro gravatar image

Trying your first suggestion and having two print jobs is certainly an option. The problem I have is that I start recording a macro, set the paper to tray 2 and then print page 1, set it to paper tray 1 and print pages 2 onwards. I then stop the macro and save it. During the recording process the printer spits out the pages on the correct paper.

When I then run that macro absolutely nothing happens. The recorded macro looks like this:

sub MainPrint
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:Print", "", 0, Array())

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

end sub

It seems to me that the macro is very light on detail. When I record it, I go into 'Printer Settings' and then 'Properties' and have to choose the paper tray from within there (the same place you would select the tray if you were viewing the printer properties from the Windows control panel). I simply cannot see anywhere else to choose the paper tray other than in the "Page Style" modify options.

thanks again for your help

edit flag offensive delete link more


It's really better to dive into the macro language and forget about recording macros. Begin right here.

floris v gravatar imagefloris v ( 2016-12-01 18:39:10 +0100 )edit

answered 2016-11-28 15:29:54 +0100

floris v gravatar image

I'd say: print the document in two print jobs, first page from tray 2 and the rest from tray 1. Assuming that the used page styles never set a value for the tray to use that should work. As this is very obvious, there's probably a snag.

Alternatively, you'd have to figure out how to address all page styles used in a document and be sure that the first page of any document always has a page style not used anywhere else in that document.

edit flag offensive delete link more

answered 2016-12-02 11:18:09 +0100

peterwt gravatar image

In the Options for LO it states for macro recording "Enable macro recording (limited)". Recording a macro does not always create the desired result.

I recorded a macro to print and it created a similar result as the macro you posted. The reason it does not print when run is that strangely the line to execute the print is preceded by REM.

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

If you remove the REM then it does print but brings up the print dialog box first. It seems that the macro recorder does not record the selections made in the print dialog - one of the limitations I guess.

As @floris v said you will need to look into programming this in Basic. The example he pointed to does show selection of the Tray but does this by changing the Page Format.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-11-28 12:23:47 +0100

Seen: 153 times

Last updated: Dec 02 '16