I have some code that looks like this:

sub x()
Dim PgBrk, n as Long, BreakLine as Long, i as Long
.
.
for i = 1 to something
If something is true Then
ActiveSheet.HPageBreaks.Add before:=Range("A" & BreakLine)
Endif
next i
.
.
n=1
For Each PgBrk in ActiveSheet.HPageBreaks
do something
n=n+1
Next PgBrk
End Sub

Execution stops on the For statement with a "Subscript out or Range" error. n=1 so it fails at the start of the first iteration.
When I enter:
?ActiveSheet.HPageBreaks.count
in the immediate window it returns a count of 8 as expected.
Also, when I look at the ActiveSheet, the page breaks are indeed there in their correct places.

Why would I get the Subscript out of range error when there are 8 entries in the collection?

Thanks for any help.