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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel PageBreak code not working as expected?

Status
Not open for further replies.

Apollo6

Technical User
Jan 27, 2000
418
US
I have a worksheet that I need to insert 4 pagebreaks at the end of a procedure. The code runs all the way through but the pagebreaks I've put in through VBA are not setting. Any suggestions would be greatly appreciated.

The following is the code snippet:

With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "Recap of Practice Charges To" & Chr(10) & "Research Charges" & Chr(10) & "By Payor" & Chr(10) & " " & strFromChrtDte & " Through " & strToChrtDte
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.19)
.BottomMargin = Application.InchesToPoints(0.05)
.HeaderMargin = Application.InchesToPoints(0.25)
.FooterMargin = Application.InchesToPoints(0.01)
.PrintHeadings = False
.PrintGridlines = True
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 5
End With

ActiveSheet.ResetAllPageBreaks
With Worksheets("INDIV")
.HPageBreaks.Add .Range("A35")
.HPageBreaks.Add .Range("A65")
.HPageBreaks.Add .Range("A94")
.HPageBreaks.Add .Range("A124")
End With
 
I took out the ZOOM property and it is now inserting the pagebreaks where I want but Excel is putting in it's "Default" pagebreaks... I've tried the following code but with no success.

ActiveSheet.ResetAllPageBreaks
With Worksheets("INDIV")
.HPageBreaks.Add .Range("A35")
.HPageBreaks.Add .Range("A65")
.HPageBreaks.Add .Range("A94")
.HPageBreaks.Add .Range("A124")
End With

Worksheets("INDIV").Rows(29).PageBreak = xlPageBreakNone
Worksheets("INDIV").Rows(59).PageBreak = xlPageBreakNone
Worksheets("INDIV").Rows(89).PageBreak = xlPageBreakNone
Worksheets("INDIV").Rows(118).PageBreak = xlPageBreakNone
Worksheets("INDIV").Rows(146).PageBreak = xlPageBreakNone

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top