Printer orientation with multi pages

  • Thread starter Thread starter skuzapo
  • Start date Start date
S

skuzapo

Hi - I'm printing a number of pages from a multi mage control on a
userform.
I need to print it landscape but don't know how to set the orientation
programatically.

Any hints?
Thanks
 
Turn on the macro recorder and do it manually.

Then look at the recorded code.

Use only the properties you need to actually set as there is a significant
overhead for the execution of each line.
 
Hi Tom,

I've got the following bit of code from the macro I recorded.

Sub Macro1()

ActiveSheet.PageSetup.PrintArea = "$B$4:$E$17"
With ActiveSheet.PageSetup
..Orientation = xlLandscape
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

I'm trying to print landscape from a multpage control though so when I
use the "Activesheet.PageSetup" the user form still prints in
Portrait.

The Multipage control doesn't support something like:

With Me.mpgCalculations.Pages
..Orientation = xlLandscape
End With

Am I missing something here?
Thanks for your help...
 
You would probably need to copy an image of the userform on which the
multipage is hosted, and paste that on a sheet, then print the sheet with
the printarea set to the area occupied by the image.

the basic approach would be:

Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)

'Public Const VK_SNAPSHOT = &H2C

Public Const VK_SNAPSHOT = 44
Public Const VK_LMENU = 164
Public Const KEYEVENTF_KEYUP = 2
Public Const KEYEVENTF_EXTENDEDKEY = 1


Sub Test()
UserForm1.Show
End Sub


In the userform module:




Private Sub CommandButton1_Click()
' keybd_event VK_SNAPSHOT, 0, 0, 0
DoEvents
keybd_event VK_LMENU, 0, _
KEYEVENTF_EXTENDEDKEY, 0 ' key down
keybd_event VK_SNAPSHOT, 0, _
KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, _
KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
keybd_event VK_LMENU, 0, _
KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
DoEvents
Workbooks.Add
Application.Wait Now + TimeValue("00:00:01")
ActiveSheet.PasteSpecial Format:="Bitmap", _
Link:=False, DisplayAsIcon:=False
ActiveSheet.Range("A1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top