ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel(2007) crashes on quering for DrawingObjects selection (https://www.excelbanter.com/excel-programming/381722-excel-2007-crashes-quering-drawingobjects-selection.html)

ranga

Excel(2007) crashes on quering for DrawingObjects selection
 
Hi All,

I am trying to to capture a selected image from the excel (2007)sheet.
I am quering for DrawingObjects in the selection. Excel crashes in the
statement
'pDispatch-QueryInterface(__uuidof(MSExcel::DrawingObjects), (LPVOID*)&pDwo);'


Here is the piece of code that i am using

IDispatch *pDispatch = m_Application-GetSelection();

if (pDispatch == NULL)
return bRetVal;

CComQIPtr<MSExcel::Range ranges;
ranges = m_Application-GetSelection();

MSExcel::DrawingObjects * pDwo = NULL;
pDispatch-QueryInterface(__uuidof(MSExcel::DrawingObjects), (void
**)&pDwo);

When the last statment gets executed, excel crashes.

can anyone tell me i have missed anything to make it work on Office
2007 Excel


Jim Rech

Excel(2007) crashes on quering for DrawingObjects selection
 
I am not a C++ developer but I've found that to get some of my old VBA code
to run under XL2007 I had to replace some uses of DrawingObjects with
Shapes.

--
Jim
"ranga" wrote in message
oups.com...
| Hi All,
|
| I am trying to to capture a selected image from the excel (2007)sheet.
| I am quering for DrawingObjects in the selection. Excel crashes in the
| statement
|
'pDispatch-QueryInterface(__uuidof(MSExcel::DrawingObjects), (LPVOID*)&pDwo);'
|
|
| Here is the piece of code that i am using
|
| IDispatch *pDispatch = m_Application-GetSelection();
|
| if (pDispatch == NULL)
| return bRetVal;
|
| CComQIPtr<MSExcel::Range ranges;
| ranges = m_Application-GetSelection();
|
| MSExcel::DrawingObjects * pDwo = NULL;
| pDispatch-QueryInterface(__uuidof(MSExcel::DrawingObjects), (void
| **)&pDwo);
|
| When the last statment gets executed, excel crashes.
|
| can anyone tell me i have missed anything to make it work on Office
| 2007 Excel
|




All times are GMT +1. The time now is 02:09 AM.

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