keks
Board Regular
- Joined
- Jul 1, 2003
- Messages
- 83
Hi again!
i spent an hour trying to resove this but it seems i won't do without your help
i have MyBook.xls that contains a sheet named "MySheet" and a command bar named "MyCommandBar". I want MyCommandBar to be visible only when the user sees MySheet, and respectively to be hidden all other time. I tried the code below but it doesn't help when i switch from MySheet in MyBook.xls to SomeOtherSheet in SomeOtherBook.xls. In this case MyCommandBar remains visible in SomeOtherSheet.
Please help me coorect my code or suggest your own. big thanks in advznce
[placed in ThisWorkbook]
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
On Error Resume Next
If ThisWorkbook.Name = Application.ActiveWorkbook.Name And Application.ActiveSheet.Name = "MySheet" Then
Application.CommandBars("MyCommandBar").Visible = True
Else
Application.CommandBars("MyCommandBar").Visible = False
End If
End Sub
i spent an hour trying to resove this but it seems i won't do without your help
i have MyBook.xls that contains a sheet named "MySheet" and a command bar named "MyCommandBar". I want MyCommandBar to be visible only when the user sees MySheet, and respectively to be hidden all other time. I tried the code below but it doesn't help when i switch from MySheet in MyBook.xls to SomeOtherSheet in SomeOtherBook.xls. In this case MyCommandBar remains visible in SomeOtherSheet.
Please help me coorect my code or suggest your own. big thanks in advznce
[placed in ThisWorkbook]
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
On Error Resume Next
If ThisWorkbook.Name = Application.ActiveWorkbook.Name And Application.ActiveSheet.Name = "MySheet" Then
Application.CommandBars("MyCommandBar").Visible = True
Else
Application.CommandBars("MyCommandBar").Visible = False
End If
End Sub