Printing A Form

J

Jeffrey

I am trying to use VBA to print an excel form. I use the
object.PrintForm method. However the form is printed in portrait mode
when I want it printed in Landscape mode. How do I get the printed
output to come out in Landscape mode? I want to be able to do this in
VBA.

Thanks.
 
D

dizzykid

Jeffrey,

Use this line:
ActiveSheet.PageSetup.Orientation = xlLandscape

If you're interested in further fine tuning of the print job, try this:
-Tools> Macro> Record new macro
-File>Page set up
-set any options you want and click OK
-click the stop recording button
-now go to VBA and look over the code Excel created
Only the settings you change need to be kept, the rest can be deleted.
HTH,
Chris
 
R

Ron de Bruin

Tom posted this from Orlando Magalhaes Filho last year
*******************************************

Following code was posted previously by Orlando Magalhaes Filho:

In a general module put in these declarations/code:

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 code module of the Userform:

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

This takes a "picture" of the userform and pastes it on a sheet. It then
prints the picture on the sheet. You should be able to modify it to get
the print settings you want.

Regards,
Tom Ogilvy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top