Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems Inserting Page Breaks in Excel when Printing

Status
Not open for further replies.

AnnaWnz

MIS
Dec 10, 2002
22
0
0
NZ
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
 
Have you tried to play with VPageBreaks.Add ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi


Have just discovered that this works okay in Excel 2000 but not in 97 - and most of our stuff is in 97. Is some part of the code only applicable to 2000, and if so, is there a way around it in 97?

Thanks in advance.

Anna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top