I have added a button into the excel toolbar,I wrote the code to
respond a buttonclick,and my purpose is to add an activex control i
wrote myself,its name is "OCXTEST.OcxtestCtrl.1",but it fails.Every
time I click the button,excel shutdown.But if I replace
"OCXTEST.OcxtestCtrl.1" with _T("Form.ListBox.1"),it passed.
And if i use COleVariant,I have to add a header"afxdisp",but in this
case,it even can't compile successfully.Why?And if you want i can send
you the project!
The main code is here:
using namespace MSExcel;
CComPtr <MSExcel::_Application> m_ExcelApp;
CComPtr <MSExcel::Shapes> m_Shapes;
IDispatchPtr m_ActiveSheet;

m_ActiveSheet=m_ExcelApp->GetActiveSheet();

m_Shapes=((_WorksheetPtr)m_ActiveSheet)->GetShapes();

// HINSTANCE result=ShellExecute(NULL, _T("open"),
_T("http://club.excelhome.net"), NULL,NULL, SW_SHOW);

// COleVariant ClassType("OCXTEST3.Ocxtest3Ctrl.1");
HRESULT
hr=m_Shapes->AddOLEObject("OCXTEST.OcxtestCtrl.1",vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing,vtMissing);
if(FAILED(hr))
return ;
return;