ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VPageBreak Problem (https://www.excelbanter.com/excel-programming/319275-vpagebreak-problem.html)

Bill Below

VPageBreak Problem
 
Hi,

I am automating Excel from MFC (Is this the right forum?) and using
something like the following code:
..
..
CVPageBreaks oVPBs = oSheet.get_VPageBreaks();
int npb = oVPBs.get_Count();
for (i = 0; i < npb; i++)
{
CVPageBreak oVPB = oVPBs.get_Item(i + 1);
oRange = oVPB.get_Location();
int cc = oRange.get_Column();
..
..
}
..
..
// show Excel to the user
theApp.m_oExcel.put_Visible(TRUE);

This works when npb is 2 but for an example where npb is 5 I get an
exception on the get_Item when i = 1 i.e. the second page break. The error
code is 8002000b or invalid index. If I move the put_Visible up so all this
happens with Excel on the screen it works again. The same thing happens with
Excel 2000 on Win2k and with Excel 2003 on XP. Any Ideas?

Thanks,
Bill


All times are GMT +1. The time now is 11:17 AM.

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