pagesetup object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I believe that I should be able to "pass" the parameter settings of one
pagesetup on a worksheet to another and thus having the same headers,
footers, margins, print areas and such without having to declare each
setting....

private sub setupworksheetprintarea()

dim w as worksheet
dim wkb as workbook
dim pg as pagesetup

set w = thisworkbook.activesheet

set wkb = workbooks.add


set wkb.activesheet.pagesetup = w.pagesetup


end sub


I am only speculating but I think it should work...
 
It sure would be nice if it did. But I betting it didn't work when you tried
it, huh?
 
Steven,
As Dave says, it won't work.
See the help for the PageSetUp property:
<Help>
Returns a PageSetup object that contains all the page setup settings for the
specified object. Read-only.
</Help>
Note the Read-Only. so:

Private Sub CommandButton2_Click()
Dim PSetUp As PageSetup
'This works
Set PSetUp = ThisWorkbook.Worksheets(1).PageSetup
'This fails
Set ThisWorkbook.Worksheets(2).PageSetup = PSetUp

End Sub

NickHK
 
The code that Tom included from John Green uses xl4 macros and can be much
faster.
 
thanks Dave. this little tidbit is pretty good.

Dave Peterson said:
The code that Tom included from John Green uses xl4 macros and can be much
faster.
 

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

Back
Top