Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Printing a UserForm

I am slowly learning VBA Excel and love this forum. I have a UserForm (named
frmSalesSummary) that I like to print out with every sales order. I
currently have this code to print the form:

frmSalesSummary.PrintForm

The problem I am having is the form does not fit the page well. How can I
adjust how the userform prints? Is it possible to do a page setup like you
do with a worksheet?

Huge Thanks in Advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Printing a UserForm

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


RyanH wrote:

I am slowly learning VBA Excel and love this forum. I have a UserForm (named
frmSalesSummary) that I like to print out with every sales order. I
currently have this code to print the form:

frmSalesSummary.PrintForm

The problem I am having is the form does not fit the page well. How can I
adjust how the userform prints? Is it possible to do a page setup like you
do with a worksheet?

Huge Thanks in Advance!


--

Dave Peterson
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
userform printing ewagz Excel Programming 3 September 20th 06 08:29 AM
Userform Printing sparx Excel Discussion (Misc queries) 8 July 31st 06 08:59 AM
Printing a Userform Brad Excel Programming 2 June 28th 06 03:19 PM
Userform - Printing Greg B Excel Discussion (Misc queries) 8 March 13th 05 02:40 PM
Userform - Printing Greg B[_4_] Excel Programming 8 March 13th 05 02:40 PM


All times are GMT +1. The time now is 03:09 AM.

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

About Us

"It's about Microsoft Excel"