Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Printer orientation with multi pages

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
skuzapo - 21 Feb 2006 02:11 GMT
Hi - I'm printing a number of pages from a multi mage control on a
userform.
I need to print it landscape but don't know how to set the orientation
programatically.

Any hints?
Thanks

Signature

skuzapo

Tom Ogilvy - 21 Feb 2006 02:32 GMT
Turn on the macro recorder and do it manually.

Then look at the recorded code.

Use only the properties you need to actually set as there is a significant
overhead for the execution of each line.

Signature

Regards,
Tom Ogilvy

> Hi - I'm printing a number of pages from a multi mage control on a
> userform.
[quoted text clipped - 3 lines]
> Any hints?
> Thanks
skuzapo - 21 Feb 2006 18:56 GMT
Hi Tom,

I've got the following bit of code from the macro I recorded.

Sub Macro1()

ActiveSheet.PageSetup.PrintArea = "$B$4:$E$17"
With ActiveSheet.PageSetup
.Orientation = xlLandscape
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

I'm trying to print landscape from a multpage control though so when I
use the "Activesheet.PageSetup" the user form still prints in
Portrait.

The Multipage control doesn't support something like:

With Me.mpgCalculations.Pages
.Orientation = xlLandscape
End With

Am I missing something here?
Thanks for your help...

Signature

skuzapo

Tom Ogilvy - 21 Feb 2006 21:15 GMT
You would probably need to copy an image of the userform on which the
multipage is hosted, and paste that on a sheet, then print the sheet with
the printarea set to the area occupied by the image.

the basic approach would be:

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

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    ' key down
   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

Signature

Regards,
Tom Ogilvy

> Hi Tom,
>
[quoted text clipped - 21 lines]
> Am I missing something here?
> Thanks for your help...
skuzapo - 21 Feb 2006 23:35 GMT
Thanks for your detailed assistance Tom.
I'll try that out.
Cheers

Signature

skuzapo

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.