Problem with printform
I tried the suggestions but the userform still went off the printed page.
Piecing together various suggestions, I found that this code works well and
prints only the userform. Note the orientation and zoom statements.
Thanks for all of the help and suggestions that made this possible.
Public Const VK_SNAPSHOT = &H2C
Public Const VK_LMENU = &HA4
Public Const VK_CONTROL = &H11
Public Const VK_V = &H56
Public Const VK_0x79 = &H79
Public Const KEYEVENTF_EXTENDEDKEY = &H1
Public Const KEYEVENTF_KEYUP = &H2
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As
Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Sub PrintThisForm_Click()
Dim sAppOs As String
Dim wks As Worksheet
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Call keybd_event(VK_LMENU, VK_V, KEYEVENTF_EXTENDEDKEY, 0)
Call keybd_event(VK_SNAPSHOT, VK_0x79, KEYEVENTF_EXTENDEDKEY, 0)
Call keybd_event(VK_LMENU, VK_V, KEYEVENTF_EXTENDEDKEY Or
KEYEVENTF_KEYUP, 0)
Call keybd_event(VK_SNAPSHOT, VK_0x79, KEYEVENTF_EXTENDEDKEY Or
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
ActiveSheet.PageSetup.Orientation = xlLandscape
ActiveSheet.PageSetup.Zoom = 80
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
End Sub
|