ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Me.PrintForm - landscape (https://www.excelbanter.com/excel-programming/331357-me-printform-landscape.html)

Henry[_5_]

Me.PrintForm - landscape
 
I've set up my form, filled it in, and now I want to print it.
Me.PrintForm does print the form but it prints portrait.
I want it printed landscape.
Any one know how to do it?

Henry



Jim Cone

Me.PrintForm - landscape
 
Henry,

Show the form. Copy it using Alt+Prt Scrn keys.
Dismiss the form.
Paste into a blank Excel sheet. Print it the way you want.

Jim Cone
San Francisco, USA


"Henry" wrote in message
...
I've set up my form, filled it in, and now I want to print it.
Me.PrintForm does print the form but it prints portrait.
I want it printed landscape.
Any one know how to do it?
Henry



Henry[_5_]

Me.PrintForm - landscape
 
Jim,
Thanks, but that's not what I want.

This program is for children and everything must be as automatic as
possible.
There's a "Print" button on the form which I use to print the form.
At the moment I've got.

Sub PrintButton_Click()
Me.PrintForm
End Sub

That prints the form, but portrait style.
I need to adjust the code to make it print landscape.

Henry

"Jim Cone" wrote in message
...
Henry,

Show the form. Copy it using Alt+Prt Scrn keys.
Dismiss the form.
Paste into a blank Excel sheet. Print it the way you want.

Jim Cone
San Francisco, USA


"Henry" wrote in message
...
I've set up my form, filled it in, and now I want to print it.
Me.PrintForm does print the form but it prints portrait.
I want it printed landscape.
Any one know how to do it?
Henry





Dave Peterson[_5_]

Me.PrintForm - landscape
 
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

I added a line that changed the orientation to landscape.

Henry wrote:

I've set up my form, filled it in, and now I want to print it.
Me.PrintForm does print the form but it prints portrait.
I want it printed landscape.
Any one know how to do it?

Henry


--

Dave Peterson

Henry[_5_]

Me.PrintForm - landscape
 
Thanks Dave, Tom and Orlando.
What a lot of code for what seemed a simple problem.
I'll try it later.

Once again, thanks.

Henry

"Dave Peterson" wrote in message
...
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

I added a line that changed the orientation to landscape.

Henry wrote:

I've set up my form, filled it in, and now I want to print it.
Me.PrintForm does print the form but it prints portrait.
I want it printed landscape.
Any one know how to do it?

Henry


--

Dave Peterson





All times are GMT +1. The time now is 10:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com