Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Greg B
 
Posts: n/a
Default Userform - Printing

Hi all I have a problem I am using the following code,

Private Sub cmdPrint_Click()
frmOrders.PrintForm
End Sub

How is it possible to get the userform to be printed in landscape

Thanks in advance

Greg



  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Greg,

You could throw up a print dialog and allow the user to select landscape
(and even the printer if required), and then print after, something like

Private Sub cmdPrint_Click()
Dim fOK As Boolean
Dim sPrinter As String

With Application
sPrinter = .ActivePrinter
fOK= .Dialogs(xlDialogPrinterSetup).Show
End With

If fOK= Then
frmOrders.PrintForm
Application.ActivePrinter = sPrinter
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Greg B" wrote in message
...
Hi all I have a problem I am using the following code,

Private Sub cmdPrint_Click()
frmOrders.PrintForm
End Sub

How is it possible to get the userform to be printed in landscape

Thanks in advance

Greg





  #3   Report Post  
Greg B
 
Posts: n/a
Default

Thanks for your help but it is not working right.

I have a userform called "totals" It shows all the information in a nice
layout.

The trouble is it continues to print in portrait even when the settings are
set at landscape.

Is it possible to print a userform in landscape? Is there a setting I am
not using.

Thanks again
Greg


  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

See one more response to your other thread.

Greg B wrote:

Hi all I have a problem I am using the following code,

Private Sub cmdPrint_Click()
frmOrders.PrintForm
End Sub

How is it possible to get the userform to be printed in landscape

Thanks in advance

Greg


--

Dave Peterson
  #5   Report Post  
Greg B
 
Posts: n/a
Default

I have used the other response from Bob Phillips and it still prints
portrait.

I posted this twice because my isp must have been down.

Sorry for the double post

Greg




  #6   Report Post  
Bob Phillips
 
Posts: n/a
Default

Greg,

Here is a technique that does work (I tested it :-) which Tom Oguily posted
some time back

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 VK_SNAPSHOT = 44
Private Const VK_LMENU = 164
Private Const KEYEVENTF_KEYUP = 2
Private Const KEYEVENTF_EXTENDEDKEY = 1



Private Sub cmdPrint_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.PageSetup.Orientation = xlLandscape
ActiveSheet.Range("A1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close Savechanges:=False
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Greg B" wrote in message
...
Thanks for your help but it is not working right.

I have a userform called "totals" It shows all the information in a nice
layout.

The trouble is it continues to print in portrait even when the settings

are
set at landscape.

Is it possible to print a userform in landscape? Is there a setting I am
not using.

Thanks again
Greg




  #7   Report Post  
Greg B
 
Posts: n/a
Default

Thanks again Bob

Greg


  #8   Report Post  
Dave Peterson
 
Posts: n/a
Default

But I wasn't writing about Bob's response.

(although his new response looks quite similar to the one I posted (Thanks to
Tom!).)

Greg B wrote:

I have used the other response from Bob Phillips and it still prints
portrait.

I posted this twice because my isp must have been down.

Sorry for the double post

Greg


--

Dave Peterson
  #9   Report Post  
Bob Phillips
 
Posts: n/a
Default


"Dave Peterson" wrote in message
...
But I wasn't writing about Bob's response.

(although his new response looks quite similar to the one I posted (Thanks

to
Tom!).)


The same I would say (apart from where the API stuff is declared), and I did
credit Tom, although I spelt his surname incorrectly (apologies Tom)/


  #10   Report Post  
Junior Member
 
Posts: 1
Angry

Quote:
Originally Posted by Bob Phillips
Greg,

Here is a technique that does work (I tested it :-) which Tom Oguily posted
some time back

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 VK_SNAPSHOT = 44
Private Const VK_LMENU = 164
Private Const KEYEVENTF_KEYUP = 2
Private Const KEYEVENTF_EXTENDEDKEY = 1



Private Sub cmdPrint_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.PageSetup.Orientation = xlLandscape
ActiveSheet.Range("A1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close Savechanges:=False
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Greg B" wrote in message
...
Thanks for your help but it is not working right.

I have a userform called "totals" It shows all the information in a nice
layout.

The trouble is it continues to print in portrait even when the settings

are
set at landscape.

Is it possible to print a userform in landscape? Is there a setting I am
not using.

Thanks again
Greg

Thanks for this, but surely SURELY there is a better way to do this! Taking a screen capture and pasting it into a new work book is a ridiculously complicated way of solving this issue!

Also you should add the following code:

ActiveSheet.PageSetup.Zoom = False
ActiveSheet.PageSetup.FitToPagesTall = 1
ActiveSheet.PageSetup.FitToPagesWide = 1

after ActiveSheet.PageSetup.Orientation = xlLandscape

to ensure it prints on one page only.
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 Greg B Excel Discussion (Misc queries) 8 March 13th 05 02:40 PM
Cell borders printing black instead of grey julie@mwfc Excel Discussion (Misc queries) 1 February 23rd 05 12:19 AM
How can I run a macro in the background whilst a UserForm is visib cdb Excel Discussion (Misc queries) 3 February 10th 05 06:58 PM
problem printing to PDF mark kubicki Excel Discussion (Misc queries) 1 January 21st 05 06:19 PM
Enable Double sided printing contiuously when printing multiple s. Lee Excel Discussion (Misc queries) 1 November 27th 04 01:58 AM


All times are GMT +1. The time now is 04:16 AM.

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"