PDA

View Full Version : Print userform horizontally



ulfal028
09-27-2006, 06:59 AM
How do I print this orientated horizontally?


UserForm2.PrintForm

Bob Phillips
09-27-2006, 07:24 AM
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

ulfal028
09-27-2006, 07:38 AM
That's quite some solution, I see where it's heading... Although, I get a 1004 error with this line:
ActiveSheet.PasteSpecial FORMAT:="Bitmap", Link:=False, DisplayAsIcon:=False
Any ideas? ShowModal is set to 'False', so that shouldn't be a problem.

Bob Phillips
09-27-2006, 07:47 AM
It works fine here. Can you post your workbook?

ulfal028
09-27-2006, 08:19 AM
Sure, here it goes. Thanks for helping me out on this.