Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Guys,
I'm tearing my hair out over this one - I just can't see what I'm doing wrong. I'm trying to alter the PageSetup properties in a Workbook_BeforePrint event, but no matter what I do I can't seem to get VBA to actually change the settings. After the code is run, the page looks the same as it always has. I've run a watch on the PageSetup object and its properties seem unaffected by my code. Yet ActiveSheet.Name returns the name of the sheet I'm trying to alter. What's going on?? ' QUOTE ' Code in Module1 ' ----- Public PrintMini as Boolean Sub TogglePrint() PrintMini = True ActiveSheet.PrintOut preview:=True End Sub ' Code in ThisWorkbook ' ----- Sub Workbook_BeforePrint(Cancel As Boolean) Application.ScreenUpdating = False With ActiveSheet.PageSetup GetLastRow ActiveSheet ' Returns a value for public integer LastRow If PrintMini = True Then .PrintArea = "A1:I" & LastRow + 4 PrintMini = False Else .PrintArea = "A1:AF" & LastRow + 4 End If .FitToPagesTall = Int(LastRow / 40) + 1 .Zoom = False .FitToPagesWide = 1 .CenterHorizontally = True .Orientation = xlLandscape .PrintTitleRows = ActiveSheet.Range("1:2").Address End With Application.ScreenUpdating = True End Sub ' END QUOTE Thanks in advance, Tristan |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
PageSetup Macro | Excel Worksheet Functions | |||
PageSetup | Excel Discussion (Misc queries) | |||
Slooooow PageSetup | Excel Programming | |||
PageSetup | Excel Programming | |||
PageSetup | Excel Programming |