Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Problem with printform

I am trying to use PrintForm but when the form prints the right portion of
the form is off of the paper (I am using 1280x1024 screen resolution).

How can I print the form as it is displayed on the screen. I cannot
require users to change their printer definitions.

Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Problem with printform

PrintForm offers no options. You can use the below code and scale the
pictu (modify to suit your particular needs).

This was posted by
"Orlando Magalhães Filho"

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
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close False
End Sub

--
Regards,
Tom Ogilvy

wrote in message
...
I am trying to use PrintForm but when the form prints the right portion of
the form is off of the paper (I am using 1280x1024 screen resolution).

How can I print the form as it is displayed on the screen. I cannot
require users to change their printer definitions.

Thank you.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Problem with printform

this version of the code only gets the Userform itself:


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
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close False
End Sub

--
Regards,
Tom Ogilvy
"Tom Ogilvy" wrote in message
...
PrintForm offers no options. You can use the below code and scale the
pictu (modify to suit your particular needs).

This was posted by
"Orlando Magalhães Filho"

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
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close False
End Sub

--
Regards,
Tom Ogilvy

wrote in message
...
I am trying to use PrintForm but when the form prints the right portion

of
the form is off of the paper (I am using 1280x1024 screen resolution).

How can I print the form as it is displayed on the screen. I cannot
require users to change their printer definitions.

Thank you.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Problem with printform

Part of the suggestion was:
scale the pictu (modify to suit your particular needs).


You chose to scale the printout - same result - glad you got it to work.

--
Regards,
Tom Ogilvy



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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM
printform vba BlackBlade Excel Programming 0 November 24th 03 06:28 AM
".printform" M Excel Programming 1 November 10th 03 06:31 PM
PrintForm Problem!! Sebastien[_2_] Excel Programming 0 July 13th 03 06:26 PM


All times are GMT +1. The time now is 01:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"