ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding Custom OCX to Excel in Add In (https://www.excelbanter.com/excel-programming/282784-adding-custom-ocx-excel-add.html)

Ali C

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.


All times are GMT +1. The time now is 01:39 PM.

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