LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Protecting and Unprotecting multiple sheets

I assume you've figured out the problem by now, but for the sake of anyone else reading...

Don't include the equal sign (=) between the Unprotect method and the password argument. Use it like this:

WkSht.Unprotect Pword


Also, you'll often want to remember the Protected state just before you Unprotect. You can use a series of Boolean variables to do that. Here's an example.

Dim blnDrawingObjects As Boolean
Dim blnContents As Boolean
Dim blnScenarios As Boolean
Dim blnAutoFilter As Boolean
Dim blnOutlining As Boolean
Dim blnPivotTable As Boolean
Dim blnUserInterface As Boolean

With ThisWorkbook.Worksheets("MyWorksheetName")

'
' remember the protection state of the sheet
'
blnDrawingObjects = .ProtectDrawingObjects
blnContents = .ProtectContents
blnScenarios = .ProtectScenarios
blnAutoFilter = .EnableAutoFilter
blnOutlining = .EnableOutlining
blnPivotTable = .EnablePivotTable
blnUserInterface = .ProtectionMode

.Unprotect "MyPassword"

' do some stuff here that requires unprotected sheet
 
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
Protecting/Unprotecting all sheets with macro leads to "image" iss MikeR Excel Worksheet Functions 3 February 22nd 10 09:33 PM
protecting and unprotecting Fusion1337 Excel Worksheet Functions 5 September 26th 08 04:03 PM
Macro for protecting and unprotecting multiple worksheets saltnsnails Excel Discussion (Misc queries) 7 January 24th 08 10:49 PM
PROTECTING/UNPROTECTING SHEETS Maureen Excel Discussion (Misc queries) 1 January 6th 05 06:46 PM
Beta - unprotecting multiple sheets Rick[_15_] Excel Programming 1 September 14th 03 09:44 PM


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