I went digging and found this code on another forum. I've tested it and it works to fix the problem of shrinking the form so that it fits on the printed page.
'=================
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12
'================================================= ====================
Private Sub CommandButton1_Click()
Dim wb As Workbook
Dim sh As Worksheet
CommandButton1.SetFocus
AltPrintScreen
DoEvents
Application.ScreenUpdating = False
Set wb = Workbooks.Add(template:=xlWBATWorksheet)
Set sh = wb.Sheets(1)
sh.Paste
With sh.PageSetup
.FitToPagesTall = 1
.FitToPagesWide = 1
.Orientation = xlPortrait
.Zoom = False
End With
sh.PrintOut
wb.Close False
Application.ScreenUpdating = True
Set sh = Nothing
Set wb = Nothing
End Sub
'================================================= =========================
Private Sub AltPrintScreen()
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
End Sub
|