Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default A problem with HPageBreaks

Hello is there an issue with playing with HPageBreaks, I have the following
code

Sub newPageIfRangeOver(rng as Range)

Dim pageBreaks As HPageBreaks
Dim pageBreak As HPageBreak
Set pageBreaks = Sheets(rng.Worksheet.name).HPageBreaks

For Each pageBreak In pageBreaks
...
Next pageBreak
End Sub

This Sub is called a number of times depending on data recieved, it has
started to just say "Subscript out of range" yet if I step through the the
program slowley, it works, no error. I'm just wondering if there is an error
with the HPageBreak Object that I perhaps I have overlooked.

Thanks in advance for any help thrown my way.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 342
Default A problem with HPageBreaks

Playing with page breaks is a very tricky affair because the automatic page
breaks are generated by excel and are not static. The "Subscript out of
range" might be because excel has not updated the page breaks. I find that
when I open a workbook excel does not see all of the page breaks until I
actually schroll down to the end of the document. Once I schroll down the
automatic page breaks are available to VGA.

A trick that I have used is to switch to "Page Break Preview Mode" which
seems to resolve the problem. Switching to a from "Page Break Preview Mode"
can be done within your code to avoid the hassle of doing it manually.

Hope this helps.

Tom

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default A problem with HPageBreaks

Seems to have done the trick, thanks alot matey.

I owe you a cold frosty beer.

"TomPl" wrote:

Playing with page breaks is a very tricky affair because the automatic page
breaks are generated by excel and are not static. The "Subscript out of
range" might be because excel has not updated the page breaks. I find that
when I open a workbook excel does not see all of the page breaks until I
actually schroll down to the end of the document. Once I schroll down the
automatic page breaks are available to VGA.

A trick that I have used is to switch to "Page Break Preview Mode" which
seems to resolve the problem. Switching to a from "Page Break Preview Mode"
can be done within your code to avoid the hassle of doing it manually.

Hope this helps.

Tom

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 159
Default A problem with HPageBreaks

Hello,

I got the trick too. I try to access the Excel Worksheets HPageBreaks. I
can get the COUNT of the HPageBreaks. But when I start to loop the pagebreaks
by using a integer index and the index 1, Microsoft.Office.Interop.Excel
always give me error: €śinvalid index€ť (The object has 17 pagebreaks). It can
get the first pagebreak in the pagebreaks only, not the others. Do you think
this is also related to "Page Break Preview Mode" ?

Thanks,
Larry

"NateBuckley" wrote:

Seems to have done the trick, thanks alot matey.

I owe you a cold frosty beer.

"TomPl" wrote:

Playing with page breaks is a very tricky affair because the automatic page
breaks are generated by excel and are not static. The "Subscript out of
range" might be because excel has not updated the page breaks. I find that
when I open a workbook excel does not see all of the page breaks until I
actually schroll down to the end of the document. Once I schroll down the
automatic page breaks are available to VGA.

A trick that I have used is to switch to "Page Break Preview Mode" which
seems to resolve the problem. Switching to a from "Page Break Preview Mode"
can be done within your code to avoid the hassle of doing it manually.

Hope this helps.

Tom

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange problem with HPageBreaks Ron de Bruin Excel Programming 0 June 29th 08 11:13 AM
HPageBreaks.Add Stephen Plotnick Excel Programming 2 July 7th 07 01:41 AM
HPageBreaks.Add GeorGeorGe Excel Worksheet Functions 0 February 9th 05 09:31 PM
More HpageBreaks Strangeness BillzyBop Excel Programming 0 June 23rd 04 03:40 AM
HPageBreaks oddities... Alex T Excel Programming 3 June 8th 04 02:01 PM


All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"