Bonjour à tous

Je suis nouveau et j'ai un soucis concernant une macro word.
Actuellement la macro marcherait correctement.
En cliquant sur un bouton cela c'était un fichier word qui se mettait en local C:\GOC-CRL\


Je dois désormais enregistrer le fichier sur le réseau au lieu du local.
J'ai changé chaque fois que je voyais le nom du répertoire en local en mettant le chemin du réseau :
"c:\goc-crl" devenant : "\\serveur\repertoire1\repertertoire2"

L’exécution du fichier entraîne un debogage
Pourriez vous m'aider à corriger ce léger bug svp ?
Est ce un problème de droits, de commande ?

Merci de votre aide.

Ci-dessous le code en question :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
Private Sub CommandButton11_Click()
'
' enregistrer
'
'Sélectionner le signet "Texte1"
'ActiveDocument.Bookmarks(DATEVOL).Select
'Récupérer le contenu du signet "Texte1"
Dim Dateduvol As String, Nrovol As String, Depart As String
Dim Arrivee As String, Immat As String, NroOFP As String
Dim Nomfic As String
Dim year As String, month As String, day As String
Dim num As Integer
Dim saved As Integer
Dim rejet As String
 
Call Repertoires
 
ChangeFileOpenDirectory "C:\GOC-CRL\"
With ActiveDocument
    rejet = ""
    Dateduvol = ActiveDocument.Bookmarks("DATEVOL").Range.Text
    Nrovol = ActiveDocument.Bookmarks("FLTNBR").Range.Text
    Depart = ActiveDocument.Bookmarks("APD").Range.Text
    Arrivee = ActiveDocument.Bookmarks("APA").Range.Text
    Immat = ActiveDocument.Bookmarks("REG").Range.Text
    NroOFP = ActiveDocument.Bookmarks("OFP").Range.Text
 
    If ActiveDocument.FormFields("NOCOMMENT").CheckBox.Value = True Then
    rejet = "NO COMMENT"
    End If
 
    If ActiveDocument.FormFields("SEECOMMENTS").CheckBox.Value = True Then
    rejet = "SEE COMMENTS"
    End If
 
    If ActiveDocument.FormFields("REJECTED").CheckBox.Value = True Then
    rejet = "REJECTED"
    End If
 
'convertir date
        Nomfic = Dateduvol
        Nomfic = Replace(Nomfic, " FORMTEXT ", "")
        year = Right(Nomfic, 4)
        month = Left(Right(Nomfic, 7), 2)
        day = Left(Nomfic, 2)
 
    'Nomfic = Dateduvol & " #" & NroOFP & Depart & "-" & Arrivee & Immat
    Nomfic = year & month & day & "_" & "#" & NroOFP & "_" & Nrovol & "_" & Depart & "-" & Arrivee & "_" & Immat & "_" & rejet
    Nomfic = Replace(Nomfic, "FORMTEXT ", "")
    Nomfic = Replace(Nomfic, " ", "")
 
    num = 0
    saved = 0
    Do While saved = 0
        If Dir("C:\GOC-CRL\" & Nomfic & "v" & num & ".doc") = "" Then
 
        ActiveDocument.SaveAs FileName:=Nomfic & "v" & num & ".doc", FileFormat:=wdFormatDocument, _
        LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
        :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
        False
        saved = 1
        Else
          num = num + 1
        End If
    Loop
 
   ' ActiveDocument.SaveAs FileName:=Nomfic & ".doc", FileFormat:=wdFormatDocument, _
  '  LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
  '  :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
  '  SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
  '  False
 
 
    Dim strName As String
        ActiveDocument.Save
        strName = Left(ActiveDocument.FullName, Len(ActiveDocument.FullName) - 4)
        strName = strName
        ActiveDocument.ExportAsFixedFormat OutputFileName:=strName, _
                                   ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
                                   wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, to:=99, _
                                   Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
                                   CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
                                   BitmapMissingFonts:=True, UseISO19005_1:=True
 
    MsgBox "File saved " & "C:\GOC-CRL\" & Nomfic & "v" & num & ".doc"
End With
End Sub
 
 
 
Private Sub CommandButton1_Click()
'
' envoie un mail avec la pièce jointe
'
Dim ol As Object, monItem As Object
Dim Dateduvol As String, Nrovol As String, Depart As String
Dim Arrivee As String, Immat As String, NroOFP As String
Dim subj As String
Dim rejet As String
rejet = ""
    Dateduvol = ActiveDocument.Bookmarks("DATEVOL").Range.Text
    Nrovol = ActiveDocument.Bookmarks("FLTNBR").Range.Text
    Depart = ActiveDocument.Bookmarks("APD").Range.Text
    Arrivee = ActiveDocument.Bookmarks("APA").Range.Text
    Immat = ActiveDocument.Bookmarks("REG").Range.Text
    NroOFP = ActiveDocument.Bookmarks("OFP").Range.Text
 
Call CommandButton11_Click
 
    If ActiveDocument.FormFields("NOCOMMENT").CheckBox.Value = True Then
    rejet = "NO COMMENT"
    End If
 
    If ActiveDocument.FormFields("SEECOMMENTS").CheckBox.Value = True Then
    rejet = "SEE COMMENTS"
    End If
 
    If ActiveDocument.FormFields("REJECTED").CheckBox.Value = True Then
    rejet = "REJECTED"
    End If
 
Set ol = CreateObject("outlook.application")
Set monItem = ol.CreateItem(olMailItem)
'REACTIVER LES ADRESSES
monItem.to = "reports@go-centre.com; <a href="mailto:longrange@go-centre.com">longrange@go-centre.com</a>; <a href="mailto:operations@corsair.fr">operations@corsair.fr</a>; <a href="mailto:ppv@corsair.fr">ppv@corsair.fr</a>; <a href="mailto:sblandino@corsair.fr">sblandino@corsair.fr</a>; <a href="mailto:asdourmap@corsair.fr">asdourmap@corsair.fr</a>"
subj = Dateduvol & " #" & NroOFP & Nrovol & Depart & "-" & Arrivee & Immat & "_" & rejet
subj = Replace(subj, "FORMTEXT ", "")
monItem.Subject = subj
monItem.Body = "Hello" & Chr(13) & Chr(13) & "Sent from CORSAIR - automatically sent - " & rejet
Set mondoc = monItem.Attachments
mondoc.Add ActiveDocument.FullName
monItem.Send
Set ol = Nothing
 
 
If rejet = "REJECTED" Then
Set ol = CreateObject("outlook.application")
Set monItem = ol.CreateItem(olMailItem)
'REACTIVER LES ADRESSES
monItem.to = "Anthony.Byer@tuifly.com; <a href="mailto:sblandino@corsair.fr">sblandino@corsair.fr</a>; <a href="mailto:asdourmap@corsair.fr">asdourmap@corsair.fr</a>"
subj = Dateduvol & " #" & NroOFP & Nrovol & Depart & "-" & Arrivee & Immat & "_" & rejet
subj = Replace(subj, "FORMTEXT ", "")
monItem.Subject = subj
monItem.Body = "Hello" & Chr(13) & Chr(13) & "REJECTED OFP - Sent from CORSAIR - automatically sent"
Set mondoc = monItem.Attachments
mondoc.Add ActiveDocument.FullName
monItem.Send
Set ol = Nothing
    End If
 
 
 
 
MsgBox "Form sent to GOC"
End Sub
 
 
Private Sub CommandButton12_Click()
'
' envoie un mail avec la pièce jointe
'
Dim ol As Object, monItem As Object
Dim Dateduvol As String, Nrovol As String, Depart As String
Dim Arrivee As String, Immat As String, NroOFP As String
Dim subj As String
    Dateduvol = ActiveDocument.Bookmarks("DATEVOL").Range.Text
    Nrovol = ActiveDocument.Bookmarks("FLTNBR").Range.Text
    Depart = ActiveDocument.Bookmarks("APD").Range.Text
    Arrivee = ActiveDocument.Bookmarks("APA").Range.Text
    Immat = ActiveDocument.Bookmarks("REG").Range.Text
    NroOFP = ActiveDocument.Bookmarks("OFP").Range.Text
 
Set ol = CreateObject("outlook.application")
Set monItem = ol.CreateItem(olMailItem)
 
'REACTIVER LES ADRESSES
monItem.to = "operations@corsair.fr; <a href="mailto:ppv@corsair.fr">ppv@corsair.fr</a>; <a href="mailto:sblandino@corsair.fr">sblandino@corsair.fr</a>; <a href="mailto:asdourmap@corsair.fr">asdourmap@corsair.fr</a>"
'monItem.Subject = "Test controle OFP"
 
subj = Dateduvol & " #" & NroOFP & Nrovol & Depart & "-" & Arrivee & Immat
subj = Replace(subj, "FORMTEXT ", "")
monItem.Subject = subj
monItem.Body = "Hello" & Chr(13) & Chr(13) & "Sent from GOC - automatically sent"
Set mondoc = monItem.Attachments
mondoc.Add ActiveDocument.FullName
monItem.Send
Set ol = Nothing
MsgBox "Form sent to CRL"
End Sub
 
 
Sub Repertoires()
  If Dir("c:\GOC-CRL", vbDirectory) = "" Then MkDir ("c:\GOC-CRL")  ' Si le répertoire "Répertoire" n'existe pas on le crée
End Sub