Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dicaprio
 
Posts: n/a
Default How to add an ActiveX control in Excel?

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?
The main code is he
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,vt Missing,vtMissing,vtMissing,vtMissing,vtMissing,vt Missing,vtMissing,vtMissing,vtMissing);
if(FAILED(hr))
return ;
return;

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
Display form from an VB application in Excel kuhni Excel Discussion (Misc queries) 0 August 10th 05 06:04 PM
date format in excel not in line with control panel regional setti GrahamR Excel Discussion (Misc queries) 3 August 2nd 05 06:48 PM
Do you know of a Calibration Control spreadsheet in Excel? Wordummy Excel Worksheet Functions 0 July 28th 05 08:21 PM
Difference in number of Excel NewsGroups Hari Prasadh Excel Discussion (Misc queries) 1 January 25th 05 11:32 AM


All times are GMT +1. The time now is 10:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"