protection vba avec excel 2003

F

francoisd25

Guest
j'avais écrit 2 s/prog en vba pour proteger (et déprotéger) toutes les feuilles d'un classeur excel. Ca fonctionnait bien sous excel 97 et 2000 mais ça ne fonctionne plus sous excel 2003!!! Quel'un a-t-il un remède à mon problème. Merci d'avance

Public Sub Protection()
réponse = InputBox("Entrer OUI ou NON", "Protection", "OUI")
If réponse = "OUI" Then
For Each w In Application.ActiveWorkbook.Sheets
If w.Protect = False Then
w.Protect
End If
Next
End If
End Sub

Public Sub Déprotection()
réponse = InputBox("Entrer OUI ou NON", "Déprotection", "OUI")
If réponse = "OUI" Then
For Each w In Application.ActiveWorkbook.Sheets
If w.Protect = True Then
w.Unprotect
End If
Next
End If
End Sub
 
M

michel

Guest
bonsoir Francois

je n'ai qu'Excel2002 pour faire des essais , mais tu déja peux tester cette adaptation


Sub Protection()
Dim Reponse As String
Dim w As Worksheet
Reponse = InputBox("Entrer OUI ou NON", "Protection", "OUI")
If Reponse = "OUI" Then
For Each w In ActiveWorkbook.Sheets
w.Protect
Next
End If
End Sub

Sub Déprotection()
Dim w As Worksheet
Dim Reponse As String
Reponse = InputBox("Entrer OUI ou NON", "Déprotection", "OUI")
If Reponse = "OUI" Then
For Each w In ActiveWorkbook.Sheets
w.Unprotect
Next
End If
End Sub


bonne soiree
MichelXld
 

Discussions similaires

Réponses
1
Affichages
109
Réponses
6
Affichages
196

Statistiques des forums

Discussions
311 541
Messages
2 080 546
Membres
101 239
dernier inscrit
rthomas