S
SkippyPB
I have the following VBA code in two different Excel Workbooks. Both
are Excel 2003. It works fine in one but dies immediately in the
other. Here's the code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet
Application.EnableEvents = False
Application.ScreenUpdating = False
If Application.CutCopyMode Then
'allows copying and pasting on the worksheet
GoTo errHandler
End If
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
.Top = 10
.Left = 10
.Width = 0
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
.Value = ""
End With
errHandler:
Application.ScreenUpdating = True
Application.EnableEvents = True
Exit Sub
End Sub
Debugger shows it is stopping on the Set cboTemp = statement. The
error message is:
Run Time Error '1004':
Method 'OLEObjects' of object '_Worksheet' failed
I have looked at everything I can think to look at and compared
everything between the two workbooks and cannot determine what is
missing or what is wrong. Can someone please point out what might be
wrong?
Thanks.
Steve
are Excel 2003. It works fine in one but dies immediately in the
other. Here's the code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet
Application.EnableEvents = False
Application.ScreenUpdating = False
If Application.CutCopyMode Then
'allows copying and pasting on the worksheet
GoTo errHandler
End If
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
.Top = 10
.Left = 10
.Width = 0
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
.Value = ""
End With
errHandler:
Application.ScreenUpdating = True
Application.EnableEvents = True
Exit Sub
End Sub
Debugger shows it is stopping on the Set cboTemp = statement. The
error message is:
Run Time Error '1004':
Method 'OLEObjects' of object '_Worksheet' failed
I have looked at everything I can think to look at and compared
everything between the two workbooks and cannot determine what is
missing or what is wrong. Can someone please point out what might be
wrong?
Thanks.
Steve