Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selected sheet(s) Page Setup
Hi Folks,
I'm looking to set some page stup options for the selected sheet or sheets via a macro with will run at Before_Print. I'm sure my problem has a simple solution but I think I've been looking at it for too long to see it. Because I want to account to a user selection of potentially more than a single sheet Im' am trying to work with some sort of activesheet parameter. i've tried a few combinations of For or With statements and just keep getting different errors. Dim ws As Worksheet For Each ws In ThisWorkbook.ActiveSheet ws.PageSetup.PrintArea = "$A$1:$U$90" ws.PageSetup.Orientation = xlLandscape ws.PageSetup.CenterHorizontally = True ws.PageSetup.CenterVertically = False ws.PageSetup.HeaderMargin = Application.InchesToPoints(0) ws.PageSetup.BottomMargin = Application.InchesToPoints(0.75) ws.PageSetup.FooterMargin = Application.InchesToPoints(0.5) ws.PageSetup.LeftMargin = Application.InchesToPoints(0.25) ws.PageSetup.RightMargin = Application.InchesToPoints(0.25) ws.PageSetup.TopMargin = Application.InchesToPoints(0.25) ws.PageSetup.FitToPagesTall = 1 ws.PageSetup.FitToPagesWide = 1 Next aws |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selected sheet(s) Page Setup
Dim ws As Worksheet
For Each ws In ActiveWindow.SelectedSheets With ws.PageSetup .PrintArea = "$A$1:$U$90" .Orientation = xlLandscape .CenterHorizontally = True .CenterVertically = False .HeaderMargin = Application.InchesToPoints(0) .BottomMargin = Application.InchesToPoints(0.75) .FooterMargin = Application.InchesToPoints(0.5) .LeftMargin = Application.InchesToPoints(0.25) .RightMargin = Application.InchesToPoints(0.25) .TopMargin = Application.InchesToPoints(0.25) .FitToPagesTall = 1 .FitToPagesWide = 1 End With Next ws -- HTH... Jim Thomlinson "Stephen" wrote: Hi Folks, I'm looking to set some page stup options for the selected sheet or sheets via a macro with will run at Before_Print. I'm sure my problem has a simple solution but I think I've been looking at it for too long to see it. Because I want to account to a user selection of potentially more than a single sheet Im' am trying to work with some sort of activesheet parameter. i've tried a few combinations of For or With statements and just keep getting different errors. Dim ws As Worksheet For Each ws In ThisWorkbook.ActiveSheet ws.PageSetup.PrintArea = "$A$1:$U$90" ws.PageSetup.Orientation = xlLandscape ws.PageSetup.CenterHorizontally = True ws.PageSetup.CenterVertically = False ws.PageSetup.HeaderMargin = Application.InchesToPoints(0) ws.PageSetup.BottomMargin = Application.InchesToPoints(0.75) ws.PageSetup.FooterMargin = Application.InchesToPoints(0.5) ws.PageSetup.LeftMargin = Application.InchesToPoints(0.25) ws.PageSetup.RightMargin = Application.InchesToPoints(0.25) ws.PageSetup.TopMargin = Application.InchesToPoints(0.25) ws.PageSetup.FitToPagesTall = 1 ws.PageSetup.FitToPagesWide = 1 Next aws |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selected sheet(s) Page Setup
I see, said the blind man. this works great and I can use it for a few
different reports to accomplish the same thing. Fantastic. Thank you for the fast and accurate reply! "Jim Thomlinson" wrote: Dim ws As Worksheet For Each ws In ActiveWindow.SelectedSheets With ws.PageSetup .PrintArea = "$A$1:$U$90" .Orientation = xlLandscape .CenterHorizontally = True .CenterVertically = False .HeaderMargin = Application.InchesToPoints(0) .BottomMargin = Application.InchesToPoints(0.75) .FooterMargin = Application.InchesToPoints(0.5) .LeftMargin = Application.InchesToPoints(0.25) .RightMargin = Application.InchesToPoints(0.25) .TopMargin = Application.InchesToPoints(0.25) .FitToPagesTall = 1 .FitToPagesWide = 1 End With Next ws -- HTH... Jim Thomlinson "Stephen" wrote: Hi Folks, I'm looking to set some page stup options for the selected sheet or sheets via a macro with will run at Before_Print. I'm sure my problem has a simple solution but I think I've been looking at it for too long to see it. Because I want to account to a user selection of potentially more than a single sheet Im' am trying to work with some sort of activesheet parameter. i've tried a few combinations of For or With statements and just keep getting different errors. Dim ws As Worksheet For Each ws In ThisWorkbook.ActiveSheet ws.PageSetup.PrintArea = "$A$1:$U$90" ws.PageSetup.Orientation = xlLandscape ws.PageSetup.CenterHorizontally = True ws.PageSetup.CenterVertically = False ws.PageSetup.HeaderMargin = Application.InchesToPoints(0) ws.PageSetup.BottomMargin = Application.InchesToPoints(0.75) ws.PageSetup.FooterMargin = Application.InchesToPoints(0.5) ws.PageSetup.LeftMargin = Application.InchesToPoints(0.25) ws.PageSetup.RightMargin = Application.InchesToPoints(0.25) ws.PageSetup.TopMargin = Application.InchesToPoints(0.25) ws.PageSetup.FitToPagesTall = 1 ws.PageSetup.FitToPagesWide = 1 Next aws |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Protect Sheet from Page Setup | Excel Discussion (Misc queries) | |||
Gridlines do not print, it is selected in sheet setup | Setting up and Configuration of Excel | |||
Excel page setup Sheet Print Cells Error As... | Excel Discussion (Misc queries) | |||
Excel Page Setup on selected worksheets | Excel Programming | |||
Copy Page Setup from Sheet to Sheet? | Excel Discussion (Misc queries) |