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 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| Sub verif()
'*** Déclaration des variables
Dim Version As Double, Dossier As String, Fichier As String
Dim Mauvaise As String, PasTrouve As String, Trouve As Boolean, y As Integer
Dim Wbk As Workbook
'***
Version = 1 '<-- A changer a chaque modification meme mineur du programme
'With ThisWorkbook '<-- Récupération du chemin et du nom du programme
'Dossier = .Path
'Fichier = .Name
'End With
Dossier = "J:\P09-Gestion des systemes d'information\BAO" '<-- Dossier fixé a la racine de la BAO
Fichier = "XXX" '<-- Nom du programme initial
Application.StatusBar = "Vérification de la version en cours"
Mauvaise = "Votre version n'est plus d'actualité ! Veuillez recopier la dernière version du programme qui se trouve dans le répertoire suivant : " & Dossier
PasTrouve = "Programme non réferencé ! Veuillez en informer le service informatique."
Trouve = False
y = 3
'Masquer l'ouverture du classeur "Liste PG Info"
Application.ScreenUpdating = False
'Ouverture du classeur "Liste PG Info" et affectation de ce classeur à la variable Wbk
Set Wbk = Workbooks.Open("J:\P09-Gestion des systemes d'information\BAO\Liste PG Info.xls")
With Wbk.Sheets(1)
Do While .Cells(y, 1) <> ""
If .Cells(y, 1).Value = Fichier Then
If .Cells(y, 2) = Version Then
Trouve = True
Exit Do
ElseIf .Cells(y, 2) > Version Then
MsgBox Mauvaise, vbCritical
Application.Quit
End If
End If
y = y + 1
Loop
If Trouve = False Then MsgBox PasTrouve, vbExclamation
Wbk.Close False
End With
Set Wbk = Nothing '<-- libération de la mémoire
Application.StatusBar = False
Application.ScreenUpdating = True '<-- réactivation de l'écran
End Sub |
Partager