How can get current oleobject in the worksheet?

  • Thread starter Thread starter cherishman
  • Start date Start date
C

cherishman

I add a group combobox(oleobject) to the worksheet dynamically, and add
event to those combobox. when the user change value of one of those
combobox, I want to know which combobox is clicked. I using VB.NET.
thanks!
 
Cherisman,

I think that you have to show us some code how you add that combobox and
that event to make it for us possible to help you.

Cor
 
OK£¬The code likes these:

Dim i As Integer
Dim MyControl As Excel.OLEObject
Dim tempComboBox(N) as MsForms.ComboBox
Try
For i=0 to N
MyControl = XLWorksheet.OLEObjects.add(ClassType:=ControlClassType,
link:=False, displayasicon:=False, Left:=1, Top:=1, Width:=1, Height:=1)
MyControl.LinkedCell=XLWorksheet.Cells(1,i+1)
MyControl.name="Stat"+cstr(i)
tempComboBox(i)= CType(FindControl(MyControl.Name),
msForms.CommandButton)
AddHandler tempComboBox(i).Change, AddressOf tempComboBox_change
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try

And I need the events tempComboBox_change handle different event when the
different combobox is clicked or I need know which linkedcell's value has
been change.
 
Cherisman,

When you want to use this code (it is office not something you should relay
on much people in this newsgroup). Than you need at least an event for this
AddressOf tempComboBox_change

When you set your cursor on this
tempComboBox(i).Change than hopefully you see the format of that

I hope this helps something

Cor
 

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

Back
Top