Hi
I am trying to get page breaks to insert when printing or print previewing. There are five buttons in the spreadsheet, each attached to a vba script that sets the relevant pages breaks, sets the print area, etc. All works ok, except the page breaks - any ideas??
Here is the code for one of the buttons:
Sub Print_Salary()
'
' Print_Salary Macro
Dim Wsheet As Worksheet
Set Wsheet = ActiveSheet
Wsheet.Rows(296).PageBreak = xlPageBreakManual
Wsheet.Rows(336).PageBreak = xlPageBreakManual
area = "A259:N370"
Range(area).Select
Call PageSetup2(area)
ActiveSheet.PrintPreview ''- used for testing
''Selection.PrintOut Copies:=1, Collate:=True
Application.Goto Reference:="R7C1"
Call PageSetupUndo
Wsheet.Rows(296).PageBreak = xlPageBreakNone
Wsheet.Rows(336).PageBreak = xlPageBreakNone
End Sub
Sub PageSetup2(area)
With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.PrintTitleRows = "$1:$4"
.PrintArea = area
End With
End Sub
Sub PageSetupUndo()
With ActiveSheet.PageSetup
.FitToPagesWide = False
.PrintTitleRows = False
.PrintArea = False
End With
End Sub
this is all stored in a module. The bottom two sub procedures are shared.
I have tried HPageBreaks.Add but can't get that to work either.
Cheers
Anna
I am trying to get page breaks to insert when printing or print previewing. There are five buttons in the spreadsheet, each attached to a vba script that sets the relevant pages breaks, sets the print area, etc. All works ok, except the page breaks - any ideas??
Here is the code for one of the buttons:
Sub Print_Salary()
'
' Print_Salary Macro
Dim Wsheet As Worksheet
Set Wsheet = ActiveSheet
Wsheet.Rows(296).PageBreak = xlPageBreakManual
Wsheet.Rows(336).PageBreak = xlPageBreakManual
area = "A259:N370"
Range(area).Select
Call PageSetup2(area)
ActiveSheet.PrintPreview ''- used for testing
''Selection.PrintOut Copies:=1, Collate:=True
Application.Goto Reference:="R7C1"
Call PageSetupUndo
Wsheet.Rows(296).PageBreak = xlPageBreakNone
Wsheet.Rows(336).PageBreak = xlPageBreakNone
End Sub
Sub PageSetup2(area)
With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.PrintTitleRows = "$1:$4"
.PrintArea = area
End With
End Sub
Sub PageSetupUndo()
With ActiveSheet.PageSetup
.FitToPagesWide = False
.PrintTitleRows = False
.PrintArea = False
End With
End Sub
this is all stored in a module. The bottom two sub procedures are shared.
I have tried HPageBreaks.Add but can't get that to work either.
Cheers
Anna