CreateDispatch error
Index
‹
Visual Studio
‹
MFC
Author
Message
opi
Posted:
Top
MFC >> CreateDispatch error
Hello!
When Im trying to createdispatch to Excel 10 (office xp) I get the
COleException error "Invalid class string". Hope that anyone have an
idea why!?
This is my code..
::OleInitialize(NULL);
m_pExcel = NULL;
m_pWorkBooks = NULL;
m_pWorkbook = NULL;
m_pSheets = NULL;
m_pSheet = NULL;
m_pRange = NULL;
m_FileIsOpen = false;
_Application* m_pExcel = new _Application;
COleException *oe = new COleException;
// gets this information from the registry.
CLSID clsid;
::CLSIDFromProgID(L"Excel.Application.10", &clsid);
try{
if(m_pExcel->m_lpDispatch == NULL)
{
if(!m_pExcel->COleDispatchDriver::CreateDispatch(clsid, oe)){
oe->ReportError();
delete m_pExcel;
m_pExcel = NULL;
}
}
}catch (COleDispatchException * Error){
AfxMessageBox(Error->m_strDescription);
Error->Delete();
}
oe->Delete();
if( m_pExcel ){
m_pWorkBooks = new Workbooks(m_pExcel->GetWorkbooks());
}
}
::CoUninitialize();
Thanks in advance..
Visual Studio147
Index
‹
Visual Studio
‹
MFC