Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default How to Store Passwords To Multiple Sheets and To Retain thatPasswords When the Workbook IS closed

i need a code to store password to multiple sheets and to retain that
passwords when i closed the workbook. according to my code it can
assigns a password but cannot retain the multiple passwords assigned
to multiple sheet .

Sub ProtectAll()

Pwd = InputBox("Enter your password to protect all worksheets")
If Pwd < "" Then
FormobjWSht_Input.Protect Password:=Pwd
Else
Exit Sub
End If

End Sub

Sub UnProtectAll()
'Dim Pwd As String

Pwd = InputBox("Enter your password to unprotect all worksheets",
"Password Input")
If Pwd < "" Then
On Error Resume Next
FormobjWSht_Input.Unprotect Password:=Pwd
If Err < 0 Then
MsgBox "You have entered an incorrect password. Worksheets could not "
& _
"be unprotected.", vbCritical, "Incorrect Password"
End If

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default How to Store Passwords To Multiple Sheets and To Retain that Passw

Vicky,
see if this does what you want.

Sub ProtectAll()
Dim sh As Worksheet
Dim Pwd As String

Pwd = InputBox("Enter your password to protect all worksheets")
If Pwd < "" Then

For Each sh In ActiveWorkbook.Worksheets

sh.Protect Password:=Pwd

Next sh

Else

Exit Sub

End If

End Sub

Sub UnProtectAll()
Dim sh As Worksheet
Dim Pwd As String

Pwd = InputBox("Enter your password to unprotect all worksheets",
"Password Input")

If Pwd < "" Then

On Error GoTo myerror

For Each sh In ActiveWorkbook.Worksheets

sh.Unprotect Password:=Pwd

Next sh

myerror:
If Err 0 Then

MsgBox "You have entered an incorrect password. Worksheets could
not " _
& "be unprotected.", vbCritical, "Incorrect Password"

Err.Clear

End If

End If

End Sub

--
jb


"vicky" wrote:

i need a code to store password to multiple sheets and to retain that
passwords when i closed the workbook. according to my code it can
assigns a password but cannot retain the multiple passwords assigned
to multiple sheet .

Sub ProtectAll()

Pwd = InputBox("Enter your password to protect all worksheets")
If Pwd < "" Then
FormobjWSht_Input.Protect Password:=Pwd
Else
Exit Sub
End If

End Sub

Sub UnProtectAll()
'Dim Pwd As String

Pwd = InputBox("Enter your password to unprotect all worksheets",
"Password Input")
If Pwd < "" Then
On Error Resume Next
FormobjWSht_Input.Unprotect Password:=Pwd
If Err < 0 Then
MsgBox "You have entered an incorrect password. Worksheets could not "
& _
"be unprotected.", vbCritical, "Incorrect Password"
End If

.

Reply
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
Passwords for Multiple Users of Workbook Brandy Excel Discussion (Misc queries) 6 June 18th 09 07:22 PM
Import All Sheets from Closed Workbook ryguy7272 Excel Programming 10 July 3rd 07 08:57 AM
Change passwords Multiple sheets bbc1 Excel Discussion (Misc queries) 1 December 24th 05 02:00 AM
import all sheets from a closed workbook johnpetrusa Excel Programming 2 June 4th 05 11:24 PM
Accessing All Sheets in a closed workbook jwallace Excel Programming 4 May 20th 04 10:33 AM


All times are GMT +1. The time now is 08:14 PM.

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"