LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protect sheets w/o user password prompt


When I run this code in the open workbook event. It locks all of th
formulas but still allows the use of command buttons.

But if I uncomment the line below it promps the user for a passwor
once for each sheet in the workbook(9 shts)

If I comment it out it protects everything I want but protection can b
turned off without a password

Dim Sht As Worksheet
Const Pass As String = "hello"

On Error Resume Next
For Each Sht In ThisWorkbook.Worksheets
With Sht
.Protect UserInterFaceOnly:=True
'.Unprotect Password:=Pass
.cells.Locked = False
.cells.SpecialCells(xlCellTypeFormulas).Locked = True
.Protect Password:=Pass
End With
Next Sh

--
hotherp
-----------------------------------------------------------------------
hotherps's Profile: http://www.excelforum.com/member.php...nfo&userid=505
View this thread: http://www.excelforum.com/showthread.php?threadid=32005

 
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
How do I protect a number of sheets allowing the user to add a com Prashanth KR New Users to Excel 8 August 28th 07 04:06 PM
password protect sheets rufusf Excel Worksheet Functions 2 March 7th 06 09:00 AM
Protect Excel sheets with Password Using VBA Iain Excel Programming 2 October 22nd 04 08:59 AM
Protecting Multiple sheets with prompt for password to unprotect pkley Excel Programming 1 January 10th 04 06:46 AM


All times are GMT +1. The time now is 12:28 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"