Tronsliver
Technical User
I built two dynamically added toolbars that are developed under the auto_activate command. Here is the code for sheet1:
Public Sub AutoRunSheet1()
Toolbars.Add "ClearTools1"
Toolbars("ClearTools1".Visible = True
Toolbars("ClearTools1".Position = xlLeft
End Sub
When I switch to sheet2 I deactivate the toolbars with this command:
Public Sub AutoCloseSheet1()
Toolbars("ClearTools1".Delete
End Sub
I then add another toolbar with this on sheet2:
Public Sub AutoRunSheet2()
Toolbars.Add "ClearTools2"
Toolbars("ClearTools2".Visible = True
Toolbars("ClearTools2".Position = xlLeft
End Sub
and when switching back to sheet1 I deactivate sheet2 with this:
Public Sub AutoCloseSheet2()
Toolbars("ClearTools2".Delete
End Sub
OK I hope I didn't make everyone dizzy This works great until I attempt to close the file without deactivating the toolbar. What happens is when I reopen, the program tries to again build a toolbar that is already in existence and gives me an error code.
I want to test to see if the toolbar is in existence upon closing the file, and if so, delete it before closing. I want to put the code in this procedure:
Public Sub Auto_Close()
If Toolbars("ClearTools1" = True Then
Toolbars("ClearTools1".Delete
Else
If Toolbars("ClearTools2" = True Then
Toolbars("ClearTools2".Delete
End If
End If
End Sub
What I'm attempting to do is check for an active toolbar and if "true" delete before closing the file. The code in the Procedure above does not work. Appreciate some suggestions..thank you
Public Sub AutoRunSheet1()
Toolbars.Add "ClearTools1"
Toolbars("ClearTools1".Visible = True
Toolbars("ClearTools1".Position = xlLeft
End Sub
When I switch to sheet2 I deactivate the toolbars with this command:
Public Sub AutoCloseSheet1()
Toolbars("ClearTools1".Delete
End Sub
I then add another toolbar with this on sheet2:
Public Sub AutoRunSheet2()
Toolbars.Add "ClearTools2"
Toolbars("ClearTools2".Visible = True
Toolbars("ClearTools2".Position = xlLeft
End Sub
and when switching back to sheet1 I deactivate sheet2 with this:
Public Sub AutoCloseSheet2()
Toolbars("ClearTools2".Delete
End Sub
OK I hope I didn't make everyone dizzy This works great until I attempt to close the file without deactivating the toolbar. What happens is when I reopen, the program tries to again build a toolbar that is already in existence and gives me an error code.
I want to test to see if the toolbar is in existence upon closing the file, and if so, delete it before closing. I want to put the code in this procedure:
Public Sub Auto_Close()
If Toolbars("ClearTools1" = True Then
Toolbars("ClearTools1".Delete
Else
If Toolbars("ClearTools2" = True Then
Toolbars("ClearTools2".Delete
End If
End If
End Sub
What I'm attempting to do is check for an active toolbar and if "true" delete before closing the file. The code in the Procedure above does not work. Appreciate some suggestions..thank you