I
ironhydroxide
I am having problems with the automatic page breaks.
I have written this code and it sets up the column and row widths and
heights and then sets the page breaks where they should be.
My problem is that VBA puts page breaks in also and so that throws off my
printing. the code under the ???? line is my page breaks within a loop.
Thanks for replies
Ironhydroxide
------------------------------------------------------------------------------------------------
Sheets("Picture Board Zones").Select
Do
Cells(1, ColumnLoopOne).ColumnWidth = 2
Cells(1, ColumnLoopTwo).ColumnWidth = 19.14
ColumnLoopOne = ColumnLoopOne + 2
Cells(1, ColumnLoopOne).ColumnWidth = 2
ColumnLoopOne = ColumnLoopOne + 1
ColumnLoopTwo = ColumnLoopTwo + 3
Loop Until ColumnLoopOne > 18
????????????????????????????????????????????????????????????????????????????????
ActiveSheet.VPageBreaks.Add Before:=Range("S1")
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.RightFooter = "Printed On " & Date
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
End With
Do
Cells(RowLoopOne, 1).EntireRow.RowHeight = 9.75
Cells(RowLoopTwo, 1).EntireRow.RowHeight = 146.25
Cells(RowLoopThree, 1).EntireRow.RowHeight = 38.25
Cells(RowLoopFour, 1).EntireRow.RowHeight = 18.75
RowLoopOne = RowLoopOne + 4
RowLoopTwo = RowLoopTwo + 5
RowLoopThree = RowLoopThree + 5
RowLoopFour = RowLoopFour + 5
Rows(RowLoopOne).RowHeight = 9.75
If RowLoopOne = 15 Or RowLoopOne = 30 Or RowLoopOne = 45 Or
RowLoopOne = 60 Or RowLoopOne = 75 Or RowLoopOne = 90 Or RowLoopOne = 105 Or
RowLoopOne = 120 Or RowLoopOne = 135 Or RowLoopOne = 150 Or RowLoopOne = 165
Or RowLoopOne = 180 Or RowLoopOne = 195 Then
????????????????????????????????????????????????????????????????????????????????
ActiveSheet.HPageBreaks.Add Before:=Range("A" & (RowLoopOne + 1))
End If
RowLoopOne = RowLoopOne + 1
Loop Until RowLoopOne > 200
ColumnLoopOne = 1
ColumnLoopTwo = 2
RowLoopOne = 1
RowLoopTwo = 2
RowLoopThree = 3
RowLoopFour = 4
Sheets("Picture Board ZoneAV").Select
With ActiveSheet.PageSetup
.FitToPagesWide = 1
.FitToPagesTall = False
End With
Do
Cells(1, ColumnLoopOne).ColumnWidth = 2
Cells(1, ColumnLoopTwo).ColumnWidth = 19.14
ColumnLoopOne = ColumnLoopOne + 2
Cells(1, ColumnLoopOne).ColumnWidth = 2
ColumnLoopOne = ColumnLoopOne + 1
ColumnLoopTwo = ColumnLoopTwo + 3
Loop Until ColumnLoopOne > 18
????????????????????????????????????????????????????????????????????????????????
ActiveSheet.VPageBreaks.Add Before:=Range("S1")
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.RightFooter = "Printed On " & Date
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
End With
ActiveSheet.PageSetup.PrintArea = "$A$1:$R$200"
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
ActiveSheet.HPageBreaks(1).DragOff Direction:=xlDown, RegionIndex:=1
BreakNum = 1
Do
Cells(RowLoopOne, 1).EntireRow.RowHeight = 9.75
Cells(RowLoopTwo, 1).EntireRow.RowHeight = 146.25
Cells(RowLoopThree, 1).EntireRow.RowHeight = 38.25
Cells(RowLoopFour, 1).EntireRow.RowHeight = 18.75
RowLoopOne = RowLoopOne + 4
RowLoopTwo = RowLoopTwo + 5
RowLoopThree = RowLoopThree + 5
RowLoopFour = RowLoopFour + 5
Rows(RowLoopOne).RowHeight = 9.75
If RowLoopOne = 15 Or RowLoopOne = 30 Or RowLoopOne = 45 Or RowLoopOne =
60 Or RowLoopOne = 75 Or RowLoopOne = 90 Or RowLoopOne = 105 Or RowLoopOne =
120 Or RowLoopOne = 135 Or RowLoopOne = 150 Or RowLoopOne = 165 Or RowLoopOne
= 180 Or RowLoopOne = 195 Then
????????????????????????????????????????????????????????????????????????????????
ActiveSheet.HPageBreaks.Add Before:=Range("A" & (RowLoopOne + 1))
End If
RowLoopOne = RowLoopOne + 1
Loop Until RowLoopOne > 200
------------------------------------------------------------------------------------------------
I have written this code and it sets up the column and row widths and
heights and then sets the page breaks where they should be.
My problem is that VBA puts page breaks in also and so that throws off my
printing. the code under the ???? line is my page breaks within a loop.
Thanks for replies
Ironhydroxide
------------------------------------------------------------------------------------------------
Sheets("Picture Board Zones").Select
Do
Cells(1, ColumnLoopOne).ColumnWidth = 2
Cells(1, ColumnLoopTwo).ColumnWidth = 19.14
ColumnLoopOne = ColumnLoopOne + 2
Cells(1, ColumnLoopOne).ColumnWidth = 2
ColumnLoopOne = ColumnLoopOne + 1
ColumnLoopTwo = ColumnLoopTwo + 3
Loop Until ColumnLoopOne > 18
????????????????????????????????????????????????????????????????????????????????
ActiveSheet.VPageBreaks.Add Before:=Range("S1")
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.RightFooter = "Printed On " & Date
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
End With
Do
Cells(RowLoopOne, 1).EntireRow.RowHeight = 9.75
Cells(RowLoopTwo, 1).EntireRow.RowHeight = 146.25
Cells(RowLoopThree, 1).EntireRow.RowHeight = 38.25
Cells(RowLoopFour, 1).EntireRow.RowHeight = 18.75
RowLoopOne = RowLoopOne + 4
RowLoopTwo = RowLoopTwo + 5
RowLoopThree = RowLoopThree + 5
RowLoopFour = RowLoopFour + 5
Rows(RowLoopOne).RowHeight = 9.75
If RowLoopOne = 15 Or RowLoopOne = 30 Or RowLoopOne = 45 Or
RowLoopOne = 60 Or RowLoopOne = 75 Or RowLoopOne = 90 Or RowLoopOne = 105 Or
RowLoopOne = 120 Or RowLoopOne = 135 Or RowLoopOne = 150 Or RowLoopOne = 165
Or RowLoopOne = 180 Or RowLoopOne = 195 Then
????????????????????????????????????????????????????????????????????????????????
ActiveSheet.HPageBreaks.Add Before:=Range("A" & (RowLoopOne + 1))
End If
RowLoopOne = RowLoopOne + 1
Loop Until RowLoopOne > 200
ColumnLoopOne = 1
ColumnLoopTwo = 2
RowLoopOne = 1
RowLoopTwo = 2
RowLoopThree = 3
RowLoopFour = 4
Sheets("Picture Board ZoneAV").Select
With ActiveSheet.PageSetup
.FitToPagesWide = 1
.FitToPagesTall = False
End With
Do
Cells(1, ColumnLoopOne).ColumnWidth = 2
Cells(1, ColumnLoopTwo).ColumnWidth = 19.14
ColumnLoopOne = ColumnLoopOne + 2
Cells(1, ColumnLoopOne).ColumnWidth = 2
ColumnLoopOne = ColumnLoopOne + 1
ColumnLoopTwo = ColumnLoopTwo + 3
Loop Until ColumnLoopOne > 18
????????????????????????????????????????????????????????????????????????????????
ActiveSheet.VPageBreaks.Add Before:=Range("S1")
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.RightFooter = "Printed On " & Date
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
End With
ActiveSheet.PageSetup.PrintArea = "$A$1:$R$200"
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
ActiveSheet.HPageBreaks(1).DragOff Direction:=xlDown, RegionIndex:=1
BreakNum = 1
Do
Cells(RowLoopOne, 1).EntireRow.RowHeight = 9.75
Cells(RowLoopTwo, 1).EntireRow.RowHeight = 146.25
Cells(RowLoopThree, 1).EntireRow.RowHeight = 38.25
Cells(RowLoopFour, 1).EntireRow.RowHeight = 18.75
RowLoopOne = RowLoopOne + 4
RowLoopTwo = RowLoopTwo + 5
RowLoopThree = RowLoopThree + 5
RowLoopFour = RowLoopFour + 5
Rows(RowLoopOne).RowHeight = 9.75
If RowLoopOne = 15 Or RowLoopOne = 30 Or RowLoopOne = 45 Or RowLoopOne =
60 Or RowLoopOne = 75 Or RowLoopOne = 90 Or RowLoopOne = 105 Or RowLoopOne =
120 Or RowLoopOne = 135 Or RowLoopOne = 150 Or RowLoopOne = 165 Or RowLoopOne
= 180 Or RowLoopOne = 195 Then
????????????????????????????????????????????????????????????????????????????????
ActiveSheet.HPageBreaks.Add Before:=Range("A" & (RowLoopOne + 1))
End If
RowLoopOne = RowLoopOne + 1
Loop Until RowLoopOne > 200
------------------------------------------------------------------------------------------------