S
Shatin
I have a floating toolbar in a workbook. On certain worksheets where it is
not applicable, I want to hide it. I can do it without any problem with
following code:
Private Sub Worksheet_Activate()
If CommandBars("Custom Toolbar").Visible = True Then
CommandBars("Custom Toolbar").Visible = False
End If
End Sub
Since the toolbar is specific to the workbook, I also want to hide it when
another workbook is activated. So I try same code as above:
Private Sub Workbook_Deactivate()
If CommandBars("Custom Toolbar").Visible = True Then
CommandBars("Custom Toolbar").Visible = False
End If
End Sub
However this time I have a problem. The error message is
"CommandBars("Custom Toolbar")=...Object variable or with block variable not
set". I am not sure what the problem is since same code works in the the
case of worksheets.
not applicable, I want to hide it. I can do it without any problem with
following code:
Private Sub Worksheet_Activate()
If CommandBars("Custom Toolbar").Visible = True Then
CommandBars("Custom Toolbar").Visible = False
End If
End Sub
Since the toolbar is specific to the workbook, I also want to hide it when
another workbook is activated. So I try same code as above:
Private Sub Workbook_Deactivate()
If CommandBars("Custom Toolbar").Visible = True Then
CommandBars("Custom Toolbar").Visible = False
End If
End Sub
However this time I have a problem. The error message is
"CommandBars("Custom Toolbar")=...Object variable or with block variable not
set". I am not sure what the problem is since same code works in the the
case of worksheets.