ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ActiveSheet.HPageBreaks not working (https://www.excelbanter.com/excel-programming/347682-activesheet-hpagebreaks-not-working.html)

GoFigure[_15_]

ActiveSheet.HPageBreaks not working
 

Excel version: 11 (2003 SP2)
OS: WXP SP2

In a procedure to print user-specified pages, I have a section of the
code that forces manual page breaks but the pages breaks are not taking
effect. The procedure itself is long - some 300 lines. In summary,
before the code that supposed to set the pages, the procedu


- Asks the financial quarter the user wants to print
- Then asks how many pages the user wants to print
- Sets the PrintArea accordingly


Then follows this code:


Code:
--------------------
' Remove all manual page breaks
ActiveSheet.ResetAllPageBreaks
' We set-up important PageSetup parameters set at beginning,
' so just set PrintArea
With ActiveSheet.PageSetup
.PrintArea = PA_PrintRange
End With
With ActiveSheet.HPageBreaks
' Force specific horizontal page breaks
.Add Befo=ActiveSheet.Range("B53") ' Page 1
.Add Befo=ActiveSheet.Range("B96") ' Page 2
.Add Befo=ActiveSheet.Range("B139") ' Page 3
End With

--------------------


When I put the ActiveSheet into PageView mode and step through the
".Add Before" statements, nothing at all happens.

Since I'm dealing with protected sheets, prior to the above code the
procedure unprotects the worksheet.

What have I done incorrectly?

Thanks,

- Al


--
GoFigure
------------------------------------------------------------------------
GoFigure's Profile: http://www.excelforum.com/member.php...fo&userid=4274
View this thread: http://www.excelforum.com/showthread...hreadid=492033


Leith Ross[_356_]

ActiveSheet.HPageBreaks not working
 

Hello Al,

I am using Excel 2000 on Windows XP. This code should work on you
system as well. Just make sure when you set the print area it include
Row 139.


Code
-------------------

' Remove all manual page breaks
ActiveSheet.ResetAllPageBreaks
' We set-up important PageSetup parameters set at beginning,
' so just set PrintArea
With ActiveSheet.PageSetup
.PrintArea = PA_PrintRange
End With
With ActiveSheet.HPageBreaks
' Force specific horizontal page breaks
.Add .Range("B53") ' Page 1
.Add .Range("B96") ' Page 2
.Add .Range("B139") ' Page 3
End With

-------------------


Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=49203


Tom Ogilvy

ActiveSheet.HPageBreaks not working
 
Make sure you are not using FitToPagesTall and or FitToPagesWide

--
Regards,
Tom Ogilvy



"GoFigure" wrote in
message ...

Excel version: 11 (2003 SP2)
OS: WXP SP2

In a procedure to print user-specified pages, I have a section of the
code that forces manual page breaks but the pages breaks are not taking
effect. The procedure itself is long - some 300 lines. In summary,
before the code that supposed to set the pages, the procedu


- Asks the financial quarter the user wants to print
- Then asks how many pages the user wants to print
- Sets the PrintArea accordingly


Then follows this code:


Code:
--------------------
' Remove all manual page breaks
ActiveSheet.ResetAllPageBreaks
' We set-up important PageSetup parameters set at beginning,
' so just set PrintArea
With ActiveSheet.PageSetup
.PrintArea = PA_PrintRange
End With
With ActiveSheet.HPageBreaks
' Force specific horizontal page breaks
.Add Befo=ActiveSheet.Range("B53") ' Page 1
.Add Befo=ActiveSheet.Range("B96") ' Page 2
.Add Befo=ActiveSheet.Range("B139") ' Page 3
End With

--------------------


When I put the ActiveSheet into PageView mode and step through the
".Add Before" statements, nothing at all happens.

Since I'm dealing with protected sheets, prior to the above code the
procedure unprotects the worksheet.

What have I done incorrectly?

Thanks,

- Al


--
GoFigure
------------------------------------------------------------------------
GoFigure's Profile:

http://www.excelforum.com/member.php...fo&userid=4274
View this thread: http://www.excelforum.com/showthread...hreadid=492033




GoFigure[_17_]

ActiveSheet.HPageBreaks not working
 

Thanks everyone.

Oh, but Tom, I am using FitToPagesTall and FitToPagesWide. This code i
the "We set-up important PageSetup parameters at beginning":


Code
-------------------
With ActiveSheet.PageSetup
.PrintTitleRows = "$3:$9"
.PrintTitleColumns = "$A:$A"
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 3
.Orientation = xlPortrait
.TopMargin = Application.InchesToPoints(0.82)
.BottomMargin = Application.InchesToPoints(0.57)
.HeaderMargin = Application.InchesToPoints(0.28)
.FooterMargin = Application.InchesToPoints(0.26)
.PrintHeadings = False
.PrintGridlines = False
.PrintArea = ""
End With

-------------------


Why not? I want to force this.

Thanks,

- A

--
GoFigur
-----------------------------------------------------------------------
GoFigure's Profile: http://www.excelforum.com/member.php...nfo&userid=427
View this thread: http://www.excelforum.com/showthread.php?threadid=49203



All times are GMT +1. The time now is 01:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com