Enregistrer sous et droits administrateurs

alias_2003

XLDnaute Occasionnel
Bonjour le Forum,
j'ai un code me permettant d'enregistrer mon fichier avec un nom établi, cad sans laisser le choix à l'utilisateur...
J'aimerais redonner ce choix aux administrateurs (avec à terme la demande d'un mot de passe). Voici le code :
Code:
Dim EnCours As Boolean

Private Sub Workbook_BeforeSave(ByVal SaveUI As Boolean, Cancel As Boolean)
Dim Nom As String
Dim file_name As Variant
Dim LValue As String
Dim réponse As Integer
Application.Dialogs(xlDialogSaveAs).Show
réponse = MsgBox("admin?", vbYesNo)
If réponse = vbYes Then Exit Sub
If réponse = vbNo Then
LValue = Format(Range("C1"), "yyyy-mm-dd")
  Nom = LValue & " - " & "Maison.xls"
  If EnCours = True Then Exit Sub
  EnCours = True
  Application.DisplayAlerts = False
   file_name = Application.GetSaveAsFilename(Nom, _
FileFilter:="Excel Files,*.xls,All Files,*.*", _
Title:="Save As File Name")
If file_name = False Then Exit Sub
  ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & Nom
  Application.DisplayAlerts = True
  Cancel = True
  EnCours = False
  End If
End Sub

En gros, il fonctionne, mais la msgbox apparait sans arrêt...:D

Merci à tous,
Bon dimanche
Une âme charitable aurait-elle la bonté de bidouiller mon code ?? ;)
 

Discussions similaires

Réponses
2
Affichages
266
Réponses
3
Affichages
201