1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| Private Sub BtnEnregistrer_Click()
Dim continuer As Boolean
continuer = ThisWorkbook.VerificationForm()
If continuer Then
Application.DisplayAlerts = False
ActiveWorkbook.Save
'on s'assure que le nom n'a pas deja .xls
Dim title As String
title = ThisWorkbook.Name
If Mid(title, Len(title) - 3, 4) = ".xls" Then
title = Mid(title, 1, Len(title) - 4)
End If
'si c'est la première fois qu'on sauvegarde on ajoute un numero aléatoire
If Application.Range("CEL_ETAT") + " " = " " Then
Dim nb_aleatoire As Long
nb_aleatoire = ((999999999 - 0 + 1) * Rnd + 0)
title = title & "_" & nb_aleatoire
End If
ActiveWorkbook.SaveAs filename:= _
"L'adresse de mon bibiliotheque Sharepoint" + title + ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
'on passe l'etat de la fiche a fermeture
ThisWorkbook.Sheets("Donnees").Range("D1") = "Fermeture"
'On ferme la fiche
ActiveWorkbook.Saved = True
Application.Quit
End If |
Partager