Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Low Security and this runs, Medium it doesn't - Why?

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Low Security and this runs, Medium it doesn't - Why?

The code in my first post was not as complete as it could
have been. If anyone wanted to load the code and test it,
I wanted it as perfect as possible.

'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 DeleteToolBar() 'I didn't show this macro in my
original post
On Local Error Resume Next
MyBar.Delete
On Local Error GoTo 0
End Sub

Sub CustomToolbar
DeleteToolBar 'I didn't show this line in my
original post
Set MyBar = CommandBars.Add("CustomToolbar",
msoBarFloating, , Temporary:=True) 'I didn't show this
line in my original post
MakeButton ("Page1")
MakeButton ("Page2")
MakeButton ("Page3")
'other code
With MyBar 'This 'With MyBar' was not shown in my
original post
.Protection = msoBarNoChangeVisible +
msoBarNoResize
.Width = 150
.Visible = True
.Top = 600
.Left = 700
End With
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
CustomToolBar 'my original posting had FinishToolBar
End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
EXCEL: the best tool for Small and Medium sized businesses www.exciter.gr: Custom Excel Applications! Links and Linking in Excel 0 November 28th 07 11:54 AM
ABC C39 Medium Text Font Juicyapples Excel Discussion (Misc queries) 1 January 31st 07 01:23 PM
Macro security level in excel will not change to medium or low Randy Setting up and Configuration of Excel 0 January 12th 06 10:59 PM
How can i create a scatterplot with small and medium values? casa3819 Charts and Charting in Excel 2 December 1st 05 11:27 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"