Error with OLEObjects

H

helmekki

Error with OLEObject
Hi there
My problem is : when excution gets to this line:


Code:
--------------------
Set cboTemp = ws.OLEObjects("TempCombo")
--------------------



it gives me
Code:
--------------------
Methode of OLEObjest of worksheet Failed
--------------------

Any how to solve the Error ?

Here is the whole code:


Code:
--------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet

Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
If cboTemp.Visible = True Then
With cboTemp
.Top = 10
.Left = 10
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
.Value = ""
End With
End If

errHandler:
Application.EnableEvents = True
Exit Sub

End Sub
 
N

Norman Jones

Hi Helmekki,

You code works for me.

If, however, I mis-spelled the combobox name, I would get your reported
error.

Check for subtle name errors, e.g. a leading or trailing space.
 

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