Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default protect/unprotect all sheets

I use the following code to protect/unprotect all sheets in a excel file:

Private Sub CommandButton1_Click()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:=TextBox1.Text
Else
wSheet.Protect Password:=TextBox1.Text
End If
Next wSheet
Unload Me
End Sub

It works well, but I would like that when I protect the sheets it will ask
twice for the password. Like excel ask normally when you protect sheet for
sheet.(tools, protection, protect sheet)
Who knows the code for this.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default protect/unprotect all sheets

easy, in this line:
Else
wSheet.Protect Password:=TextBox1.Text
End If

you could add an userform (a new one) that asks the password again, and if
that password is different from textbox1.text then an error msgbox appears
HTH
"roos" wrote:

I use the following code to protect/unprotect all sheets in a excel file:

Private Sub CommandButton1_Click()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:=TextBox1.Text
Else
wSheet.Protect Password:=TextBox1.Text
End If
Next wSheet
Unload Me
End Sub

It works well, but I would like that when I protect the sheets it will ask
twice for the password. Like excel ask normally when you protect sheet for
sheet.(tools, protection, protect sheet)
Who knows the code for this.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default protect/unprotect all sheets

Ok, and the code to do this?
roos

"filo666" wrote:

easy, in this line:
Else
wSheet.Protect Password:=TextBox1.Text
End If

you could add an userform (a new one) that asks the password again, and if
that password is different from textbox1.text then an error msgbox appears
HTH
"roos" wrote:

I use the following code to protect/unprotect all sheets in a excel file:

Private Sub CommandButton1_Click()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:=TextBox1.Text
Else
wSheet.Protect Password:=TextBox1.Text
End If
Next wSheet
Unload Me
End Sub

It works well, but I would like that when I protect the sheets it will ask
twice for the password. Like excel ask normally when you protect sheet for
sheet.(tools, protection, protect sheet)
Who knows the code for this.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default protect/unprotect all sheets

still there????

"filo666" wrote:

easy, in this line:
Else
wSheet.Protect Password:=TextBox1.Text
End If

you could add an userform (a new one) that asks the password again, and if
that password is different from textbox1.text then an error msgbox appears
HTH
"roos" wrote:

I use the following code to protect/unprotect all sheets in a excel file:

Private Sub CommandButton1_Click()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:=TextBox1.Text
Else
wSheet.Protect Password:=TextBox1.Text
End If
Next wSheet
Unload Me
End Sub

It works well, but I would like that when I protect the sheets it will ask
twice for the password. Like excel ask normally when you protect sheet for
sheet.(tools, protection, protect sheet)
Who knows the code for this.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default protect/unprotect all sheets

yes

"filo666" wrote:

still there????

"filo666" wrote:

easy, in this line:
Else
wSheet.Protect Password:=TextBox1.Text
End If

you could add an userform (a new one) that asks the password again, and if
that password is different from textbox1.text then an error msgbox appears
HTH
"roos" wrote:

I use the following code to protect/unprotect all sheets in a excel file:

Private Sub CommandButton1_Click()
Dim wSheet As Worksheet
For Each wSheet In Worksheets
If wSheet.ProtectContents = True Then
wSheet.Unprotect Password:=TextBox1.Text
Else
wSheet.Protect Password:=TextBox1.Text
End If
Next wSheet
Unload Me
End Sub

It works well, but I would like that when I protect the sheets it will ask
twice for the password. Like excel ask normally when you protect sheet for
sheet.(tools, protection, protect sheet)
Who knows the code for this.

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
Protect/unprotect all sheets at once? wx4usa New Users to Excel 4 July 22nd 08 12:08 AM
Protect-Unprotect all the sheets Gary Excel Worksheet Functions 7 February 26th 07 08:13 PM
Macros for Protect/Unprotect all sheets in a workbook Paul Sheppard[_2_] Excel Programming 4 August 16th 05 03:36 PM
Protect / Unprotect Sheets Rob F[_2_] Excel Programming 3 August 10th 04 02:27 PM
Protect/Unprotect Sheets Deeds[_2_] Excel Programming 1 May 27th 04 08:43 PM


All times are GMT +1. The time now is 02:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"