Creating a Custom commandbar button
First, I think I'd move that cbar stuff out of the loop.
Option Explicit
Sub CleanUpControls()
Dim cbar As CommandBar
Dim ctrl As CommandBarControl
Set cbar = Nothing
Set ctrl = Nothing
Set cbar = Application.CommandBars("PastyFellow")
Do
Set ctrl = Nothing
On Error Resume Next
Set ctrl = cbar.FindControl(Tag:="Sifar")
On Error GoTo 0
If ctrl Is Nothing Then
Exit Do
Else
ctrl.Delete
End If
Loop
cbar.Delete
End Sub
Second, on the troublesome pc, look under Tools|References.
If you see a reference marked MISSING, then maybe unchecking that reference
would fix the problem. I've never seen this error with a constant, though--but
it'll be easy to check.
sifar wrote:
Hi Dave,
Its nothing to with your code. getting the same message at a Cybercafe
PC. works fine on my Home PC.
Made some changes to your code.....
Sub CleanUpControls()
Dim cbar As CommandBar
Dim ctrl As CommandBarControl
Do
Set cbar = Nothing
Set ctrl = Nothing
On Error Resume Next
Set cbar = Application.CommandBars("PastyFellow")
Set ctrl = cbar.FindControl(Tag:="Sifar")
On Error GoTo 0
If ctrl Is Nothing Then
Exit Do
Else
ctrl.Delete
cbar.Delete
End If
Loop
End Sub
This worked fine for me by deleting the CustomCommandBar along with the
Control.
Please advice.
--
Dave Peterson
|