ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Invalid index in foreach(HPageBreak hpb in sheet.HPageBreaks) (https://www.excelbanter.com/excel-programming/376171-invalid-index-foreach-hpagebreak-hpb-sheet-hpagebreaks.html)

Amy

Invalid index in foreach(HPageBreak hpb in sheet.HPageBreaks)
 
My program got the following exception while parsing some excel files (they
usually contain some manual page breaks):
Exception from HRESULT: 0*8002000B <DISP_E_BADINDEX

I used
sheet.HPageBreaks.Count
found it contains 5 objects...
my program can get the first two objects successfully, how ever, it cannot
load the left.

Does anyone know why?
Thanks for any comments.

Tom Ogilvy

Invalid index in foreach(HPageBreak hpb in sheet.HPageBreaks)
 
http://support.microsoft.com/kb/210663/en-us
You receive an"Subscript out of range" error message when you use
HPageBreaks or VPageBreaks.Location in Excel


--
Regards,
Tom Ogilvy

"Amy" wrote in message
...
My program got the following exception while parsing some excel files
(they
usually contain some manual page breaks):
Exception from HRESULT: 0*8002000B <DISP_E_BADINDEX

I used
sheet.HPageBreaks.Count
found it contains 5 objects...
my program can get the first two objects successfully, how ever, it cannot
load the left.

Does anyone know why?
Thanks for any comments.




Amy

Invalid index in foreach(HPageBreak hpb in sheet.HPageBreaks)
 
Thanks Tom..
My problem is another issue...the program throws exception when it execute
HPageBreak hpb = sheet.HPageBreaks[i];

Usually, I call ResetAllPageBreaks(); before I get the page breaks. If I
dont reset them, the program works well.

"Tom Ogilvy" wrote:

http://support.microsoft.com/kb/210663/en-us
You receive an"Subscript out of range" error message when you use
HPageBreaks or VPageBreaks.Location in Excel


--
Regards,
Tom Ogilvy

"Amy" wrote in message
...
My program got the following exception while parsing some excel files
(they
usually contain some manual page breaks):
Exception from HRESULT: 0*8002000B <DISP_E_BADINDEX

I used
sheet.HPageBreaks.Count
found it contains 5 objects...
my program can get the first two objects successfully, how ever, it cannot
load the left.

Does anyone know why?
Thanks for any comments.






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

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