OLE combobox

G

Guest

Hi.
I have a little problem...
I have a macro that creates a OLE combobox1, with 3 different selections,
and puts it into a excel worksheet. Then when I have put the combobox into
the worksheet I have an other macro which should get the text from the
combobox and set it into av textbox which will be drawn in Visio. My problem
is to get the text from the combobox.

This code is the one I use to try to get the selected text in the combobox
in the active worksheet.

Dim shpObjComp As Visio.Shape
shpObjComp.Text = Cells(row, column).Select

But the combobox items doesn't get into the shpObjComp, the shpObjComp only
writes out "true"
Please help me! I dont know how to solve this!

/Mikkan
 
G

Guest

Can't say what is wrong without knowing more about your code. How (and why?)
are you computing the values for row and column, and why are you looking for
the text on your sheet via the Cells() property instead of directly from the
Combobox itself?
 
J

Jean-Yves

Hi,

Correct
"Cells(row, column).Select" is True
If you want the value, remove .Select
Regards
JY
 
G

Guest

Hi.
I have a function which makes the 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.combobox.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
standa´rd 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

"K Dales" skrev:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top