View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ali C Ali C is offline
external usenet poster
 
Posts: 1
Default Adding Custom OCX to Excel in Add In

Hi

I am writing an Excel 10 Add-In in VB, and I need to add some
controls to a sheet. I thought I would write my own activex control
to group them, but I am having trouble adding my control to the sheet.
My code looks like this :

Dim objWS As Worksheet
Set objWS = m_objApplication.Worksheets.Item("Configuration")
objWS.OLEObjects.Add "CtrlConfiguration.ConfigurationCtrl.1", _
Left:=10, Top:=100, Height:=20, Width:=100

My activeX project is called CtrlConfiguration, and it has a user
control called ConfigurationCtrl. When this code is executed by
pressing a button I inserted in a toolbar in Excel, I get the error :

Run-time error '1004':
Cannot insert object.

I am not sure if Excel knows about my OCX. I added a reference for
the VBA project of the xls file I am trying to run this in. I think I
am missing a setup step, or my naming of the object is incorrect.
help?

Thanx in advance.