ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Customised Toolbar Specific to only 1 Worksheet (https://www.excelbanter.com/excel-programming/357950-customised-toolbar-specific-only-1-worksheet.html)

Carmi

Customised Toolbar Specific to only 1 Worksheet
 
MS Excel 2003

I have created a custom toolbar (called Toolbar) and assigned some macros to
it. I created the toolbar using the standard right
clickcustomiseToolbarsnew.

I want the floating toolbar to only be displayed when a particular sheet is
being viewed ("Schedule") and hidden if it is not. As such under the
Schedule Sheet I have added the following code

Private Sub Worksheet_Activate()
If ActiveSheet.Name = ("Schedule") Then
CommandBars("Toolbar").Enabled = True
CommandBars("Toolbar").Visible = True
Else:
CommandBars("Toolbar").Visible = False
End If
End Sub

Enabling and showing the toolbar works when I select the schedules sheet.
However, as the schedules sheet is the default sheet displayed I need to
first select another sheet and then reselect schedules before the toolbar is
displayed.

Once the toolbar is displayed and I select another sheet (any other sheet
besides schedules) I want it to be hidden from view.... but it isnt.

I have the same problem with the toolbar being visible when I close the
workbook. I need the toolbar to be closed when the workbook is closed.

Hope one of you guys can point me in the right direction.

Thanks

Carmi

Martin

Customised Toolbar Specific to only 1 Worksheet
 
Best to attach the toolbar to your workbook. Make sure it's open and then,
in View, Toolbars, Customize click Attach then highlight your toolbar and
copy it across. Save and close the workbook and you can now delete the
toolbar to remove it from your standard Excel setup so it doesn't appear for
every other file you open.

Next, use both the Activate and Deactivate events for your worksheet:

Private Sub Worksheet_Activate()
CommandBars("test").Visible = True
End Sub

Private Sub Worksheet_Deactivate()
CommandBars("test").Visible = False
End Sub


"Carmi" wrote:

MS Excel 2003

I have created a custom toolbar (called Toolbar) and assigned some macros to
it. I created the toolbar using the standard right
clickcustomiseToolbarsnew.

I want the floating toolbar to only be displayed when a particular sheet is
being viewed ("Schedule") and hidden if it is not. As such under the
Schedule Sheet I have added the following code

Private Sub Worksheet_Activate()
If ActiveSheet.Name = ("Schedule") Then
CommandBars("Toolbar").Enabled = True
CommandBars("Toolbar").Visible = True
Else:
CommandBars("Toolbar").Visible = False
End If
End Sub

Enabling and showing the toolbar works when I select the schedules sheet.
However, as the schedules sheet is the default sheet displayed I need to
first select another sheet and then reselect schedules before the toolbar is
displayed.

Once the toolbar is displayed and I select another sheet (any other sheet
besides schedules) I want it to be hidden from view.... but it isnt.

I have the same problem with the toolbar being visible when I close the
workbook. I need the toolbar to be closed when the workbook is closed.

Hope one of you guys can point me in the right direction.

Thanks

Carmi


Carmi

Customised Toolbar Specific to only 1 Worksheet
 
Martin - thanks for your reply. Your answer was spot on... cant beleive it
was so easy!

Appreciate your help

Carmi


"Martin" wrote:

Best to attach the toolbar to your workbook. Make sure it's open and then,
in View, Toolbars, Customize click Attach then highlight your toolbar and
copy it across. Save and close the workbook and you can now delete the
toolbar to remove it from your standard Excel setup so it doesn't appear for
every other file you open.

Next, use both the Activate and Deactivate events for your worksheet:

Private Sub Worksheet_Activate()
CommandBars("test").Visible = True
End Sub

Private Sub Worksheet_Deactivate()
CommandBars("test").Visible = False
End Sub


"Carmi" wrote:

MS Excel 2003

I have created a custom toolbar (called Toolbar) and assigned some macros to
it. I created the toolbar using the standard right
clickcustomiseToolbarsnew.

I want the floating toolbar to only be displayed when a particular sheet is
being viewed ("Schedule") and hidden if it is not. As such under the
Schedule Sheet I have added the following code

Private Sub Worksheet_Activate()
If ActiveSheet.Name = ("Schedule") Then
CommandBars("Toolbar").Enabled = True
CommandBars("Toolbar").Visible = True
Else:
CommandBars("Toolbar").Visible = False
End If
End Sub

Enabling and showing the toolbar works when I select the schedules sheet.
However, as the schedules sheet is the default sheet displayed I need to
first select another sheet and then reselect schedules before the toolbar is
displayed.

Once the toolbar is displayed and I select another sheet (any other sheet
besides schedules) I want it to be hidden from view.... but it isnt.

I have the same problem with the toolbar being visible when I close the
workbook. I need the toolbar to be closed when the workbook is closed.

Hope one of you guys can point me in the right direction.

Thanks

Carmi



All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com