SkipVought
Programmer
Hi gang,
Excel behaves differently if I run my program in Normal or Page Break View. My objective is to reassign horizontal page breaks at places where my report (1 wide by 99 tall) major groups break in col 1.
It "works" in page break view (except I get a subscript out of range run time error that will continue to completion from that point)
In normal, none of the page breaks ever get inserted.
Any thoughts?
Skip,
Skip@TheOfficeExperts.com
Excel behaves differently if I run my program in Normal or Page Break View. My objective is to reassign horizontal page breaks at places where my report (1 wide by 99 tall) major groups break in col 1.
It "works" in page break view (except I get a subscript out of range run time error that will continue to completion from that point)
In normal, none of the page breaks ever get inserted.
Any thoughts?
Code:
Sub ReassignPageBreaks()
Dim pb As HPageBreak
PgSetup
ActiveSheet.ResetAllPageBreaks
For Each pb In ActiveSheet.HPageBreaks
With pb
If IsEmpty(Cells(.Location.Row, 1).Value) Then
Set pb.Location = Rows(Cells(Cells(.Location.Row, 1).End(xlUp).Row, 1).Row)
End If
End With
Next
Exit Sub
End Sub
Sub PgSetup()
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = _
"&""Arial,Bold""DAILY JOB REPORT DATABASE" & Chr(10) & "&A" & Chr(10) & "Week Ending: 1/30/2003"
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.82)
.BottomMargin = Application.InchesToPoints(0.38)
.HeaderMargin = Application.InchesToPoints(0.25)
.FooterMargin = Application.InchesToPoints(0.25)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = -2
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 99
.PrintErrors = xlPrintErrorsDisplayed
End With
End Sub
Skip@TheOfficeExperts.com