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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Déclaration des variables
Dim x As Variant
Dim y As Variant
Dim TDB As String
Dim CHEMIN_DOC As String
Dim NOM_DOC As String
Dim CHEMIN As String
Dim CONTROL_OUVERTURE As String
Dim objWord As New Word.Application
'Pour ne pas entrer dans la cellule cellectionnée
Cancel = True
'Initialisation des variables
TDB = ActiveWorkbook.Name
x = Selection.Row
y = Selection.Column
'Si click sur colonne "C"
If y = 3 Then
'Si Document non créé
If Cells(x, 35).Value = "" Then
'Si absence N° document
If Cells(x, 2).Value = "" Then
MsgBox "Veuillez indiquer un ID temporaire"
Cancel = True
Exit Sub
End If
'Si absence Titre document
If Cells(x, 3).Value = "" Then
MsgBox "Veuillez indiquer une désignation à la Field Procedure"
Cancel = True
Exit Sub
End If
'Formulaire d'initialisation du document
Template_Property.Show
'Si document crée
ElseIf Cells(x, 35).Value = "Créé" Then
'Initialisation variables
CHEMIN_DOC = "Chemin du document sur le reseau"
NOM_DOC = Cells(x, y).Value & ".docx"
CHEMIN = CHEMIN_DOC & NOM_DOC
'Vérification si document déjà ouvert par quelqu'un sur le réseau
Call TESTOUVERTURE
End If
End If
'Récupération vérification test ouverture
CONTROL_OUVERTURE = Sheets("Réglage").Range("B3").Value
'Si document non ouvert
If CONTROL_OUVERTURE = 1 Then
'ouverture du doc word
objWord.Documents.Open CHEMIN_DOC & NOM_DOC
objWord.Visible = True
'retour sur Excel
Workbooks(TDB).Activate
'Sauvegarde
ActiveWorkbook.Save
If Application.Version = "16.0" Then
'Sauvegarde
ActiveWorkbook.Save
'Fermeture
ActiveWorkbook.Close True
End If
If Application.Version = "14.0" Then
'Sauvegarde
ActiveWorkbook.Save
'Fermeture
ActiveWorkbook.Close True
End If
'Si document ouvert
ElseIf CONTROL_OUVERTURE = 0 Then
'information utilisateurs
MsgBox "Fichier en cours d'utilisation par un autre utilisateur", vbInformation
Exit Sub
End If |
Partager