ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   OleObjects and someproperties (https://www.excelbanter.com/excel-programming/351248-oleobjects-someproperties.html)

Kris

OleObjects and someproperties
 
Hi.

I inserted object; combo box

Dim combo As OLEObject

Set combo = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1",
Link:=False, DisplayAsIcon:=False, Left:=100, Top:=100.Top, Width:=96,
Height:=18)

I can set some of the properties

combo.LinkedCell = "$g$6"

but I also have to set ColumnCount and ColumnWidth properties of
combobox. I can do that manually, but they are not listed as a
properties in VBA

Ho to do that from VBA?

Thanks.



Norman Jones

OleObjects and someproperties
 
Hi Kris,

Try:

Dim combo As msforms.ComboBox


---
Regards,
Norman


"Kris" wrote in message
...
Hi.

I inserted object; combo box

Dim combo As OLEObject

Set combo = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1",
Link:=False, DisplayAsIcon:=False, Left:=100, Top:=100.Top, Width:=96,
Height:=18)

I can set some of the properties

combo.LinkedCell = "$g$6"

but I also have to set ColumnCount and ColumnWidth properties of combobox.
I can do that manually, but they are not listed as a properties in VBA

Ho to do that from VBA?

Thanks.





Chip Pearson

OleObjects and someproperties
 
Use

combo.Object.ColumnCount = 2


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Kris" wrote in message
...
Hi.

I inserted object; combo box

Dim combo As OLEObject

Set combo =
ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1",
Link:=False, DisplayAsIcon:=False, Left:=100, Top:=100.Top,
Width:=96, Height:=18)

I can set some of the properties

combo.LinkedCell = "$g$6"

but I also have to set ColumnCount and ColumnWidth properties
of combobox. I can do that manually, but they are not listed as
a properties in VBA

Ho to do that from VBA?

Thanks.





Kris

OleObjects and someproperties
 
Chip Pearson wrote:
Use

combo.Object.ColumnCount = 2



This is it.

So simple solutions are so difficult to find.

Kris

OleObjects and someproperties
 
Thanks, but it works only if you have object on userform, not on worksheet.
Thanks anyway.


Norman Jones wrote:
Hi Kris,

Try:

Dim combo As msforms.ComboBox


---
Regards,
Norman


"Kris" wrote in message
...

Hi.

I inserted object; combo box

Dim combo As OLEObject

Set combo = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1",
Link:=False, DisplayAsIcon:=False, Left:=100, Top:=100.Top, Width:=96,
Height:=18)

I can set some of the properties

combo.LinkedCell = "$g$6"

but I also have to set ColumnCount and ColumnWidth properties of combobox.
I can do that manually, but they are not listed as a properties in VBA

Ho to do that from VBA?

Thanks.







All times are GMT +1. The time now is 02:23 AM.

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