find automatic page breaks


G

Guest

This code does not work when I try to locate automatic page breaks.

Dim i As Integer, BreakType As Integer
BreakType = ActiveCell.EntireRow.PageBreak
If BreakType = xlAutomatic Or BreakType = xlPageBreakAutomatic Then
MsgBox "There is an automatic page break above this row"
ElseIf BreakType = xlManual Or BreakType = xlPageBreakManual Then
MsgBox "There is a manual page break above this row"
ElseIf BreakType = xlNone Or BreakType = xlPageBreakNone Then
MsgBox "There is no page break above this row"
Else
MsgBox "What!?"
End If

The reason for the redundant Excel constants is just the result of my
grasping at straws. I've been online for over four hours now looking for
solutions to this problem - no matter where I place the cursor, BreakType
returns -4142 (none), even when I place it on clearly displayed page breaks,
both manual and automatic. Is there some little-known issue with the
PageBreak function? I'm... just... I don't know. Anybody with some input...
please feel free. I'm using Excel on the MS Office Suite 2003.
 
Ad

Advertisements

G

Guest

I copied your code exactly into XL2002 SP2 on Windows 2000 Pro.

On a blank worksheet I got the same results as you - no page breaks found.
As soon as I populated any cell just above or below the pagebreak the code
worked as expected.

It would appear that if there is nothing to print then the pagebreak is
"ignored".

Hope this helps
Rowan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top