ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel - adding control programmatically. (https://www.excelbanter.com/excel-programming/284384-excel-adding-control-programmatically.html)

Alan B[_3_]

Excel - adding control programmatically.
 
I have a COM+ control written in C++ that I wand to use in an Excel sheet.
I can drop one into the sheet visually no problem ,add a button and talk
to my control just fine.

Then I tried to create an instance of the control programmatically
instead, inside the click code of a button. I don't want to actually add
it to the sheet, I just want to create it, query it and stick the results
in a cell. I can't get this to work. The nearest I can get is using the
OLEObjects collection of the workbook, but adding it into there actually
adds it to the sheet. Is this just the way Excel has to work, i.e.
anything you create from a control has to be contained in a sheet to work
??

--
* Need help running those old FoxPro / xBase apps on modern systems ?
* http://www.hentzenwerke.com/catalogp.../painlesse.htm

RADO[_3_]

Excel - adding control programmatically.
 
Alan,

there are several simple ways around:
1) create a hidden sheet and manipulate you control there. User won't see
anything, and on exit you can delete the sheet.

2) you can turn off screen updating, create control/use it/delete, and then
turn on screen again., User won't see a thing again.

3) you can put control on the sheet, but set your control's Visible property
to false, and it will exist only in the memory

4) finally, I think (I might be wrong) that Excel needs your control to
belong to an object, like a worksheet or a user form. As I said, you can
create a dummy sheet or an invisible user form (just initialize it and hide,
unload on exit).

Hope it helps -

RADO



"Alan B" wrote in message
...
I have a COM+ control written in C++ that I wand to use in an Excel sheet.
I can drop one into the sheet visually no problem ,add a button and talk
to my control just fine.

Then I tried to create an instance of the control programmatically
instead, inside the click code of a button. I don't want to actually add
it to the sheet, I just want to create it, query it and stick the results
in a cell. I can't get this to work. The nearest I can get is using the
OLEObjects collection of the workbook, but adding it into there actually
adds it to the sheet. Is this just the way Excel has to work, i.e.
anything you create from a control has to be contained in a sheet to work
??

--
* Need help running those old FoxPro / xBase apps on modern systems ?
* http://www.hentzenwerke.com/catalogp.../painlesse.htm




Alan B[_3_]

Excel - adding control programmatically.
 
"RADO" wrote in
:

What you actually have to do is create a reference to it.



--
* Need help running those old FoxPro / xBase apps on modern systems ?
* http://www.hentzenwerke.com/catalogp.../painlesse.htm

Alan B[_3_]

Excel - adding control programmatically.
 
"RADO" wrote in
:

What you actually have to do is create a reference to it. Then you don't
have to add it to the sheet at aall. Thx anyway.



--
* Need help running those old FoxPro / xBase apps on modern systems ?
* http://www.hentzenwerke.com/catalogp.../painlesse.htm


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

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