ACommandLineKindaGuy
Active Member
- Joined
- May 11, 2002
- Messages
- 378
- Office Version
- 365
- Platform
- Windows
I'm trying to determine to set a constant that returns whether a commandbar control is on any of the visible commandbars. This code runs when the workbook is opened...
However I get a compile error where indicated. If I modify the if statement to define the constant, I get a different compile error. The VBA help is pretty lean on explaining what the errors mean, so no progress there.
I suppose I could modify the code to this...
...but now I have no way to set the Constant to False so I can use it elsewhere. Anyone have any ideas?
Thanks
Code:
'See if we have a drawing control on a visible toolbar and log it as a constant
y = False
On Error Resume Next
For Each Cbar In Application.CommandBars
If Cbar.Visible And Not Cbar.FindControl(ID:=204) Is Nothing Then
y = True
Exit For
End If
Next Cbar
Const HaveDrawingControl As Boolean = y '<<COMPILE ERROR
However I get a compile error where indicated. If I modify the if statement to define the constant, I get a different compile error. The VBA help is pretty lean on explaining what the errors mean, so no progress there.
I suppose I could modify the code to this...
Code:
'See if we have a drawing control on a visible toolbar and log it as a constant
On Error Resume Next
For Each Cbar In Application.CommandBars
If Cbar.Visible And Not Cbar.FindControl(ID:=204) Is Nothing Then
Const HaveDrawingControl As Boolean = True
Exit For
End If
Next Cbar
...but now I have no way to set the Constant to False so I can use it elsewhere. Anyone have any ideas?
Thanks