VBA - How to define Page setup, Landscape orientation on a Userform

  • Thread starter Thread starter Frank Krogh
  • Start date Start date
F

Frank Krogh

The Userform object has a PrintForm property, but it doesn't seem to be
available any Page setup property to set a Landscape printout (except for
the sheet).

Is there a way around this shortcoming?


Thanks for suggestions

Frank Krogh
 
This was posted by
"Orlando Magalhães Filho" <[email protected]>

A while back and seems to work:

In a general module:


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

Sub Test()
UserForm1.Show
End Sub


In the userform module:


Private Sub CommandButton1_Click()
keybd_event VK_SNAPSHOT, 0, 0, 0
Workbooks.Add
Application.Wait Now + TimeValue("00:00:01")
ActiveSheet.PasteSpecial Format:="Bitmap", Link:=False,
DisplayAsIcon:=False
ActiveSheet.Range("A1").Select
' added line to orient landscape
Activesheet.PageSetup.Orientation = xlLandscape
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close False
End Sub
 
Back
Top