Setting page layout and print set up in code for a new worksheet

N

NDBC

I have just created a new worksheet with the data the way I want it. Now I
would like to set the page layout for printing to landscape and set it so it
scales to print 1 page wide by 10 pages long. Can this be done in code.

In my code the sheet is called wbNew.Sheets("results")

Thanks
 
J

Jacob Skaria

Try below. The best way would be to record a macro and review the code which
is generated....Then edit to suit your requirements...

With wbNew.Sheets("results").PageSetup
.Orientation = xlLandscape
.PaperSize = xlPaperA4
.Order = xlDownThenOver
.FitToPagesWide = 1
.FitToPagesTall = 10
End With
 
N

NDBC

Thanks again. It didn't work properly so I did what you said and found i
needed this.

With wbNew.Sheets("results").PageSetup
.Orientation = xlLandscape
.PaperSize = xlPaperA4
.Order = xlDownThenOver .Zoom= False
.FitToPagesWide = 1
.FitToPagesTall = 10
End With

I have tried using record macro before but sometimes it seems to record
stuff that needs to be changed to make vb code work in programs (eg
applications).
 

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