LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 465
Default Modifying a protect unprotect macro


Hi

All I'm hoping someone can help with placing a Yes / No popup in an
existing macro.

I use this macro to protect / unprotect my worksheets.

Sub Protect_Unprotect()


Const PWORD As String = "password"
Dim wkSht As Worksheet
Dim statStr As String

Application.ScreenUpdating = False

For Each wkSht In ActiveWorkbook.Worksheets
With wkSht
statStr = statStr & vbNewLine & "Sheet " & .Name
If .ProtectContents Then
wkSht.Unprotect Password:=PWORD
statStr = statStr & ": Unprotected"
Else
wkSht.Protect Password:=PWORD, _
DrawingObjects:=False, _
Contents:=True, _
Scenarios:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowFiltering:=True ', _
AllowFormattingCells:=True, _
AllowDeletingRows:=True, _
AllowInsertingColumns:=True, _
AllowInsertingHyperlinks:=True, _
AllowInsertingRows:=True, _
Userinterfaceonly:=True, _
AllowDeletingColumns:=True, _
AllowUsingPivotTables:=True
statStr = statStr & ": Protected"
End If
End With
Next wkSht

Application.ScreenUpdating = True

MsgBox Mid(statStr, 2)

End Sub

My problem is that for some workbooks i need all of the qualifying
permissions listed here to be reinstated on protection. In others , I
don't need them. In these the limited basic permission to select locked
/ unlocked in needed.

What I'm trying to put in place is a Yes / No popup asking 'All
qualifying permissions?'. If the answer is 'Yes' then it proceeds
through the macro. If the answer is 'No' then it jumps over the
permissions listed in the macro and protects with the basic select
locked / unlocked cells.

Can someone help with this? I did try some coding of my own , but am
struggling to find the right place in the code to place the popup VBA.

Grateful for any help.


 
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
Qualifying permissions in protect unprotect macro. Colin Hayes Excel Discussion (Misc queries) 4 April 26th 11 05:06 AM
Protect and Unprotect all worksheets with macro Joe M. Excel Discussion (Misc queries) 2 January 22nd 10 09:26 PM
Macro to Protect OK, Unprotect now messed up! Stilla Excel Worksheet Functions 12 January 7th 09 02:22 PM
400 Error in Unprotect/Protect Macro Youngergirl44 Excel Discussion (Misc queries) 1 September 23rd 08 01:29 PM
protect / unprotect VBA project by macro sylvain Excel Discussion (Misc queries) 0 July 31st 06 06:09 PM


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