![]() |
Printing userform in landscape on one page only
I found the code below that has enabled me to print a userform in landscape
mode. However, it is printing it two pages wide instead of one, cutting off the last bit of the right side of the form and printing it on page two. I tried adding the following just after the part where it sets the orientation to landscape: ActiveSheet.PageSetup.FitToPagesWide = 1 ActiveSheet.PageSetup.FitToPagesTall = 1 It didn't make a difference, however, and still printed out on two pages. Can anyone tell me what I need to change or add to the code below in order to get the userform to print on only one page? This was posted by Tom Ogilvy: Modification of code originally posted by "Orlando Magalhães Filho" Modified to capture just the userform (not the whole window). 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 = 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 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 'added to force landscape ActiveSheet.PageSetup.orientation = xlLandscape ActiveWindow.SelectedSheets.PrintOut Copies:=1 ActiveWorkbook.Close False End Sub |
Printing userform in landscape on one page only
Try including -
ActiveSheet.PageSetup.Zoom = False Regards, Peter T In passing, "Luke" wrote in message ... I found the code below that has enabled me to print a userform in landscape mode. However, it is printing it two pages wide instead of one, cutting off the last bit of the right side of the form and printing it on page two. I tried adding the following just after the part where it sets the orientation to landscape: ActiveSheet.PageSetup.FitToPagesWide = 1 ActiveSheet.PageSetup.FitToPagesTall = 1 It didn't make a difference, however, and still printed out on two pages. Can anyone tell me what I need to change or add to the code below in order to get the userform to print on only one page? This was posted by Tom Ogilvy: Modification of code originally posted by "Orlando Magalhães Filho" Modified to capture just the userform (not the whole window). 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 = 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 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 'added to force landscape ActiveSheet.PageSetup.orientation = xlLandscape ActiveWindow.SelectedSheets.PrintOut Copies:=1 ActiveWorkbook.Close False End Sub |
Printing userform in landscape on one page only
Never mind. Turns out I had to set the margins as well before it would print
solely on one page. "Luke" wrote: I found the code below that has enabled me to print a userform in landscape mode. However, it is printing it two pages wide instead of one, cutting off the last bit of the right side of the form and printing it on page two. I tried adding the following just after the part where it sets the orientation to landscape: ActiveSheet.PageSetup.FitToPagesWide = 1 ActiveSheet.PageSetup.FitToPagesTall = 1 It didn't make a difference, however, and still printed out on two pages. Can anyone tell me what I need to change or add to the code below in order to get the userform to print on only one page? This was posted by Tom Ogilvy: Modification of code originally posted by "Orlando Magalhães Filho" Modified to capture just the userform (not the whole window). 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 = 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 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 'added to force landscape ActiveSheet.PageSetup.orientation = xlLandscape ActiveWindow.SelectedSheets.PrintOut Copies:=1 ActiveWorkbook.Close False End Sub |
All times are GMT +1. The time now is 08:34 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com