ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   OLE comboboxes (https://www.excelbanter.com/excel-programming/335243-ole-comboboxes.html)

Mikkan

OLE comboboxes
 
Hi.
I have a function which makes OLE comboboxes:

Sub newCombo(intRowIndex As Integer, intColumnIndex As Integer, strSignal As
String)

Then I have a select case selection which makes an array with items for the
combobox:
Select Case intRowIndex
Case 18 + 3
varDiff = Array("Sea Water Pressure", "CC_SetPlus")
intDiffLength = 1
.....

Creation of the combobox
With Cells(intRowIndex, intColumnIndex)
'Create a OLE oject and set size and add it to the active sheet
Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.combo box.1", _
Left:=.Left, Top:=.Top, Width:=.Width,
Height:=.Height)


combo.AddItem (strSignal)

'Add the other choices to the combobox
For j = 0 To intDiffLength
combo.AddItem (varDiff(j))
Next j
'Set the standard choice to be chosen
combo.ListIndex = 0

Thats the macro which makes the comboboxes and sets the items and the
standard choice.

Then I have another macro which will look in the excel sheet and take the
value of the cell and put in a variable. Then I create a visio document and a
shape and I want to assign the text from the excel sheet to the shape. It
works great for an usuall cell, but it doesn't work for the comboboxes. I
dont know how to take the value from an OLE combobox.

this is what i do to take the value of the excel cell.
shpObjComp.Text = Cells(varPinNrA(i) + 2, intColumn + 1)

Perhaps it would work if the cell which the combobox lies in knows what the
combobox is showing, but i don't know how to do that!
HELP please!

/Mikkan


William Benson[_2_]

OLE comboboxes
 
Doesn't the combo box have a linked cell property, and cannot you take the
value from that cell and not the combo?
"Mikkan" wrote in message
...
Hi.
I have a function which makes OLE comboboxes:

Sub newCombo(intRowIndex As Integer, intColumnIndex As Integer, strSignal
As
String)

Then I have a select case selection which makes an array with items for
the
combobox:
Select Case intRowIndex
Case 18 + 3
varDiff = Array("Sea Water Pressure", "CC_SetPlus")
intDiffLength = 1
....

Creation of the combobox
With Cells(intRowIndex, intColumnIndex)
'Create a OLE oject and set size and add it to the active sheet
Set oOLE =
ActiveSheet.OLEObjects.Add(ClassType:="Forms.combo box.1", _
Left:=.Left, Top:=.Top, Width:=.Width,
Height:=.Height)


combo.AddItem (strSignal)

'Add the other choices to the combobox
For j = 0 To intDiffLength
combo.AddItem (varDiff(j))
Next j
'Set the standard choice to be chosen
combo.ListIndex = 0

Thats the macro which makes the comboboxes and sets the items and the
standard choice.

Then I have another macro which will look in the excel sheet and take the
value of the cell and put in a variable. Then I create a visio document
and a
shape and I want to assign the text from the excel sheet to the shape. It
works great for an usuall cell, but it doesn't work for the comboboxes. I
dont know how to take the value from an OLE combobox.

this is what i do to take the value of the excel cell.
shpObjComp.Text = Cells(varPinNrA(i) + 2, intColumn + 1)

Perhaps it would work if the cell which the combobox lies in knows what
the
combobox is showing, but i don't know how to do that!
HELP please!

/Mikkan





All times are GMT +1. The time now is 07:41 AM.

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