M
MarkAtlanta
code:
-----------------------------------------------------------
'At top of this module
Dim MyBar As CommandBar
Dim MadeButton As CommandBarButton
Dim Page1Button As CommandBarButton
Dim Page2Button As CommandBarButton
Dim Page3Button As CommandBarButton
Dim Sheetname As String
Sub CustomToolbar
'code to set up toolbar and assign other buttons
MakeButton ("Page1")
MakeButton ("Page2")
MakeButton ("Page3")
'other code
End sub
Sub MakeButton(Sheetname)
Set MadeButton = MyBar.Controls.Add
(Type:=msoControlButton)
With MadeButton
.Style = msoButtonIconAndCaption
If Worksheets(Sheetname).Visible <> -1 Then
.Caption = "Show '" & Sheetname & "'"
.FaceId = 170
.State = msoButtonUp
Else
.Caption = "Hide '" & Sheetname & "'"
.FaceId = 171
.State = msoButtonDown
End If
.OnAction = "'HideShow """ & Sheetname & """'"
End With
End Sub
Sub HideShow(Sheetname)
If Worksheets(Sheetname).Visible = -1 Then
Worksheets(Sheetname).Visible = 2
Else: Worksheets(Sheetname).Visible = -1
Worksheets(Sheetname).Select
End If
FinishToolBar
End Sub
-----------------------------------------------------------
When a user has their Tools, Macro, Security, Security
Levels, set to Low, this Macro runs just fine. However
when they have it set to Medium (and they Enable Macros),
they can click on one of these buttons, but no sheets are
made visible or hidden. Trying to figure it out, when I
put MsgBox Sheetname as the first line of HideShow, it
never pops up. So it looks like the .onaction event is
disabled by the medium security level setting. Does this
make any sense? I know how to get around this (hard code
the buttons instead using loops and variables, or I can
require that the users set their Security to Low) so that
isn't my question. My question is what do I do to get
this work, or same thing is different between Low and
Medium-Enable. Thank you all so much!
-----------------------------------------------------------
'At top of this module
Dim MyBar As CommandBar
Dim MadeButton As CommandBarButton
Dim Page1Button As CommandBarButton
Dim Page2Button As CommandBarButton
Dim Page3Button As CommandBarButton
Dim Sheetname As String
Sub CustomToolbar
'code to set up toolbar and assign other buttons
MakeButton ("Page1")
MakeButton ("Page2")
MakeButton ("Page3")
'other code
End sub
Sub MakeButton(Sheetname)
Set MadeButton = MyBar.Controls.Add
(Type:=msoControlButton)
With MadeButton
.Style = msoButtonIconAndCaption
If Worksheets(Sheetname).Visible <> -1 Then
.Caption = "Show '" & Sheetname & "'"
.FaceId = 170
.State = msoButtonUp
Else
.Caption = "Hide '" & Sheetname & "'"
.FaceId = 171
.State = msoButtonDown
End If
.OnAction = "'HideShow """ & Sheetname & """'"
End With
End Sub
Sub HideShow(Sheetname)
If Worksheets(Sheetname).Visible = -1 Then
Worksheets(Sheetname).Visible = 2
Else: Worksheets(Sheetname).Visible = -1
Worksheets(Sheetname).Select
End If
FinishToolBar
End Sub
-----------------------------------------------------------
When a user has their Tools, Macro, Security, Security
Levels, set to Low, this Macro runs just fine. However
when they have it set to Medium (and they Enable Macros),
they can click on one of these buttons, but no sheets are
made visible or hidden. Trying to figure it out, when I
put MsgBox Sheetname as the first line of HideShow, it
never pops up. So it looks like the .onaction event is
disabled by the medium security level setting. Does this
make any sense? I know how to get around this (hard code
the buttons instead using loops and variables, or I can
require that the users set their Security to Low) so that
isn't my question. My question is what do I do to get
this work, or same thing is different between Low and
Medium-Enable. Thank you all so much!