# Solved: Printing A form in Excel in Landscape using VBA



## TMeerkat (Jun 23, 2011)

Hi there
I need to print a form in landscape format.
I wrote the VBA code to print like this:
_Main1.PrintForm_
It prints however on a Portrait page and therefore cuts off some of the form itself.
What code can I use to set the printing page for the form to Landscape?


----------



## Keebellah (Mar 27, 2008)

These codes can be used in vba:


```
With ActiveSheet.PageSetup
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter =""
        .LeftMargin = Application.InchesToPoints(0.49)
        .RightMargin = Application.InchesToPoints(0.57)
        .TopMargin = Application.InchesToPoints(0.3)
        .BottomMargin = Application.InchesToPoints(0.3)
        .HeaderMargin = Application.InchesToPoints(0.58)
        .FooterMargin = Application.InchesToPoints(0.24)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = True
        .CenterVertically = False
[B][COLOR="Red"]        .Orientation = xlLandscape[/COLOR][/B]
        .Draft = False
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
    End With
```


----------



## TMeerkat (Jun 23, 2011)

Hi there

I am not printing the worksheet, I am printing the Form. does this make a difference seeing as your code starts with ActiveSheet?

Thanks
Tanya


----------



## TMeerkat (Jun 23, 2011)

Hi there

I created a Multipage UserForm and one of the pages needs to print in the UserForm. I can get the Userform to print but only in portrait.
I used the code you seggested, It changed the activesheet but did nothing for the UserFome that printed still in Portrait view.

TMeerkat


----------



## Keebellah (Mar 27, 2008)

Sorry, did not read the post correctly, I assumed a worksheet.
I don't know if that can be done. A userform is not really a printing object, you would probably have to set your printer to landscape before printing. Hav eyou Googled for this?
I found this and the conclusion is the saem, a userform is not for printing but maybe you can pick-up from there:

http://social.msdn.microsoft.com/Forums/en/isvvba/thread/def468a2-a317-496e-85a1-ab37bd449264

If I find something I'll let you know


----------



## TMeerkat (Jun 23, 2011)

Thanks for trying.

The code I mentioned above actually prints the form, it just doesn't print it in Landscape as I want.
Will look into the link you provided
Have a nice day.
TMeerkat


----------



## TMeerkat (Jun 23, 2011)

Thanks for your reply

The link was very helpful.

I just took that code and pasted into my form code and it printed correctly.
Jippeeeee!

Thanks again.
TMeerkat


----------

