How to Change Worksheet Properties

G

Guest

I have:
A macro to change page setup properties. The macro appears to run but
doesn't change the properties.

I want:
The macro needs to work if the names or number of worksheets changes (there
will always be a worksheet "Main" that begins with the wrong page setup
properties).
1. To change the print quality of all worksheets to 600 dpi.
2. To change the Fit to Page property of the "Main" worksheet to False.

Code snippet:
'Change print quality of all sheets to 600 dpi

ActiveWorkbook.Sheets.Select

With ActiveSheet.PageSetup
.PrintQuality = 600
End With

'Change the FitToPagesTall property on the Main worksheet to False

Sheets("Main").Select

With ActiveSheet.PageSetup
.FitToPagesWide = 1
.FitToPagesTall = False
End With

Any suggestions?
 
G

Guest

ActiveWorkbook.Sheets.Select

With ActiveSheet.PageSetup
.PrintQuality = 600
End With

You select all sheets, then only change properties on the activesheet.

for the most part, VBA doesn't not support grouped sheets. Loop through the
sheets and make you setting to each sheet individually.
 
G

Guest

If I understand correctly, you want to apply the settings to all sheets.
Try this

Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
With sht.PageSetup
.PrintQuality = 600
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Next sht
 

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