Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - VBA... locking out users from accessing specific tabs.

Status
Not open for further replies.

SnayJ

Programmer
Feb 27, 2008
65
US

I was wondering if there is an easy way to lock out users from accessing tabs. I found code that prevents the user from right-clicking the active tab and choosing "Unhide"... (see below)

Code:
[Indent]Application.CommandBars("Worksheet Menu Bar").Controls("F&ormat").Controls("S&heet").Controls("&Unhide...").Enabled = False[/Indent]

But of course it interfere's with VBA opening and closing hidden forms. So I've had to add True/False code to every Procedure that opens a form.... well somehow/someway, sometimes... things screw up and then I have issues opening and closing forms. It's almost like Excel is too slow and or skips code. I don't get it. Is there another way of doing this?

Also as far as Protecting pages. I have most of my datasheets protected so users can't affect them, only VBA can thru forms. I use this code:

Code:
[Indent]Dim AdminPass As String[/Indent]
[Indent]AdminPass = Sheets("Office Form").Range("U2").Value[/Indent]
[Indent]ThisWorkbook.Sheets("Office View").Unprotect Password:=AdminPass[/Indent]

Then of course, protect it again once the code has processed. Is there a better way of doing it, or is this it?
 
Form" means worksheet? Instead of annoying users with modyfying interface (they may need it for other worksheets) either in VBE or by code set sheet's visibility to xlVeryHidden. Another option is to protect workbook's structure.
You can process protected worksheet with vba, this requires repeating protecting the sheet when you open workbook (this setting is not saved):
[tt]ThisWorkbook.Sheets("Office View").Protect Password:=AdminPass, UserInterfaceOnly:=True[/tt]

combo
 
Office Form" is the name of the tab... like Sheet1.... thanks on the note for protecting the worksheet... I'll try it and get back with you. I'm not spending as much time on the project as I'd like... every other day at best.... thanks for the reply though.

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top