Error with OLEObject

hmk

Active Member
Joined
Jun 8, 2004
Messages
423
Hi there
My problem is : when excution gets to this line:
Code:
Set cboTemp = ws.OLEObjects("TempCombo")
it gives me 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
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hello, helmekki,

two possibilities come into my mind
1. you've made your combobox using the FORMS-toolbar
2. you don't have a combobox called TempCombo

kind regards,
Erik
 

Watch MrExcel Video

Forum statistics

Threads
1,118,234
Messages
5,571,042
Members
412,358
Latest member
Eng Muhammed
Top