HIDE ITEM PROTECTION IN TOOLBAR

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
I wonder if there is a possibility to hide the item protection in the toolbar,by opening workbook?
Any idea?
Thanks
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Yes you can

But do not forget to turn it back on. See all the examples here.

Private Sub Workbook_Activate()
Application.CommandBars("Tools").Controls("Protection").Enabled = False
End Sub

Private Sub Workbook_Deactivate()
Application.CommandBars("Tools").Controls("Protection").Enabled = True
End Sub

Private Sub Workbook_Open()
Application.CommandBars("Tools").Controls("Protection").Enabled = False
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Tools").Controls("Protection").Enabled = True
End Sub

Yours in EXCELent Frustration

KniteMare


_________________
Of course I can, and it will take only 900 hours of programming time to do it.
This message was edited by KniteMare on 2002-08-27 10:29
 
Upvote 0
On 2002-08-27 10:29, KniteMare wrote:

Yes you can

But do not forget to turn it back on. See all the examples here.

Private Sub Workbook_Activate()
Application.CommandBars("Tools").Controls("Protection").Enabled = False
End Sub

Private Sub Workbook_Deactivate()
Application.CommandBars("Tools").Controls("Protection").Enabled = True
End Sub

Private Sub Workbook_Open()
Application.CommandBars("Tools").Controls("Protection").Enabled = False
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Tools").Controls("Protection").Enabled = True
End Sub

Yours in EXCELent Frustration

KniteMare


_________________
Of course I can, and it will take only 900 hours of programming time to do it.
This message was edited by KniteMare on 2002-08-27 10:29
Hi,sorry but it doesn't work.I get an error 5
Maybe can be the reason that I have yet the following line in workbook_open:
Application.CommandBars(1).FindControl(ID:=522, recursive:=True).Enabled = False
Any idea?
Thanks in advance
 
Upvote 0
Is there a way to do this so that instead of just graying out the menu or menu item (as this code does), the menu or menu item is completely removed from the menu bar?

thanks,
kevin
 
Upvote 0
On 2002-08-27 14:11, kskinne wrote:
Is there a way to do this so that instead of just graying out the menu or menu item (as this code does), the menu or menu item is completely removed from the menu bar?

thanks,
kevin
Hi,

Yes.It like me better.What is the code to be completely removed from the menu bar?
Many thanks for help.
 
Upvote 0
instead of this code:

Application.CommandBars("Tools").Controls("Protection").Enabled = False

use this code:

Application.CommandBars("Tools").Controls("Protection").Visible = False

where 'enabled' is replaced by 'visible'

HTH
kevin
 
Upvote 0
On 2002-08-27 14:57, kskinne wrote:
instead of this code:

Application.CommandBars("Tools").Controls("Protection").Enabled = False

use this code:

Application.CommandBars("Tools").Controls("Protection").Visible = False

where 'enabled' is replaced by 'visible'

HTH
kevin
Sorry Kevin,but the same error.
Thanks for your time
 
Upvote 0
Try using the findcontrol id instead of the caption. The same as you did when you were disabling the option button. The control number for Protection is 30029. So your code should be as follows

Code:
Private Sub Workbook_Open()
Application.CommandBars(1).FindControl(Id:=30029, recursive:=True).Visible = False
End Sub


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars(1).FindControl(Id:=30029, recursive:=True).Visible = True
End Sub
This message was edited by Dragracer on 2002-08-27 17:00
 
Upvote 0
Dragracer,

What is the advantage of the Control Number, and How do you identify the number?

Yours in EXCELent Frustration,

KniteMare
 
Upvote 0
I am sure someone else more can explain it alot better then I can. The findcontrol method is more "stable" when working between version. "Protection" is the caption of the button ?(control) which can be changed the "id" will not change.

The best place I found to get the list of id numbers is from Microsoft.


http://support.microsoft.com/default.aspx?scid=kb;[LN];Q213552

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q213211&

or for XL97 goto

http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q159466&
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,284
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top