B
Bill Below
Hi,
I am automating Excel from MFC (I submitted this before at Excel
Programming, but maybe this is the better 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
I am automating Excel from MFC (I submitted this before at Excel
Programming, but maybe this is the better 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