problem with finding horizontal page breaks

K

Keith Willis

Hi

I'm trying to use the following code to get all the horizontal page
breaks

Dim varArray() As Variant
Dim x As Variant
Dim i As Integer

For Each x In objWkBk.Worksheets("sheet1").HPageBreaks
i = i + 1
ReDim Preserve varArray(i)
varArray(i) = x.Location.Row
Next x

objWkBk is in separate instance of excel.
The problem is if there is more than 1 page break the code errors with
a subscript out of range. Any ideas?
 
J

Jim Cone

Try it in PageBreakPreview... ActiveWindow.View = xlPageBreakPreview
You may also have to put a temporary value in an empty cell below your data.
Then remove the temp value when you are done.
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(Special Print XL add-in: long columns printed side by side)




"Keith Willis" <[email protected]>
wrote in message
news:05fc8caa-d7fc-4847-a97d-7eb9d0a18fbb@gy7g2000vbb.googlegroups.com...
 
K

Keith Willis

Thanks for reply but same error msg

Try it in PageBreakPreview... ActiveWindow.View = xlPageBreakPreview
You may also have to put a temporary value in an empty cell below your data.
Then remove the temp value when you are done.
--
Jim Cone
Portland, Oregon USAhttp://www.mediafire.com/PrimitiveSoftware
(Special Print XL add-in:  long columns printed side by side)

"Keith Willis" <[email protected]>
wrote in message
 
J

Jim Cone

N = objWkBk.Worksheets("Sheet1").HPageBreaks.Count
For X = 1 to N
varArray(X) = objWkBk.Worksheets("Sheet1").HPageBreaks(X).Location.Row
'other stuff needed
Next
'---
Might be a problem if the Application is not visible.
My original comments still apply.
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(Data Rows Excel add-in: Color rows, Delete rows, Insert rows)




"Keith Willis"
<[email protected]>
wrote in message
Thanks for reply but same error msg
 
K

Keith Willis

Tried that still the same problem.

though i've noticed that when i try to open a watch on the new
worksheet to check the pagebreaks i get the msg "system policy prevent
loading of manifests" wonder if it might be related.
 
K

Keith Willis

Curiously if i scroll through the worksheet maually to the pagebreak
that fails as i'm stepping through the code the code runs fine
 
J

Jim Cone

That's beyond my skill level. Suggest you do a web search and/or contact your system administrator.
'--
Jim Cone


"Keith Willis" <[email protected]>
wrote in message
Tried that still the same problem.

though i've noticed that when i try to open a watch on the new
worksheet to check the pagebreaks i get the msg "system policy prevent
loading of manifests" wonder if it might be related.
 
K

Keith Willis

Something a bit odd. Using your code if i scroll on the workbook the
the row with the pagebreak the code runs, but i have to do this for
each pagebreak.
 

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

Top