Printer Orientation: VBA

varunvithalani

Registered User.
Local time
Tomorrow, 03:03
Joined
May 11, 2010
Messages
19
Hello,

I wish to automatically set narrow margins and orientations before issuing a print command in the code.
This is what I have done so far:

Application.Printer.Orientation = acPRORLandscape
Application.Printer.BottomMargin = 362.834645669
Application.Printer.TopMargin = 362.834645669
Application.Printer.LeftMargin = 362.834645669
Application.Printer.RightMargin = 362.834645669
RunCommand acCmdPrintPreview
RunCommand acCmdPrint

This code works well and good on my computer which has NO PRINTERS INSTALLED. Thus the default is 'MS XPS Viewer'.

Now when I try to run the same file in another PC which has an HP printer installed, the program absolutely ignores the orientation and margin commands and shows a preview in potrait mode with normal margins.

I was wondering that the issue could be with the problem of the default printer. I need to construct the program such that it is generic and it sets the defalult printer automatically.

Kindly help with your inputs.

Thanks
 
Here is what I use to force the user's print margins when I allow them to print the current record of the active form [simple screen shot of the form]...

Code:
Printer.TopMargin = 0.25
Printer.BottomMargin = 0.25
Printer.RightMargin = 0.25
Printer.LeftMargin = 0.5
DoCmd.RunCommand acCmdSelectRecord
Me.Printer.Orientation = acPRORLandscape
'DoCmd.PrintOut , 1, 1, acHigh, 1, False
DoCmd.PrintOut acSelection
 

Users who are viewing this thread

Back
Top Bottom