Bonjour le forum,
on m'a donner un code qui selectionne des informations, les copie dans un endroit sur la même feuille, puis on selectionne ces informations et on les envoit dans un logiciel, LE code que l'on m'a donner marche parfaitement, je l'ai donc recuperer et adapter à mon cas, j'ai bien le message de fin qui s"'affiche avec "L'ECRITURE A ETE COMPTABILISEE" simplement quand je vais dans mon logiciel, l'écriture n'apparait pas. J'ai beauc chercher, je ne trouve pas l'erreur, voici mon code :
Code vba : 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
'Se connecter à la compta
Function Connecte(icc As Integer)
Dim hWnd As Long
Dim hWndCegidPgi As Long
 
If Not OkConnect Then
    CodeSoc = ""
    ' MISE EN COMMENTAIRE POUR VERSION 2006 ajout me
    'hWndCegidPgi = FindWindow(vbNullString, "CegidPgi")
    'If hWndCegidPgi <> 0 Then
    '    hWnd = FindWindow(vbNullString, "Comptabilité PGI Expert")
    'Else
    '    hWnd = FindWindow(vbNullString, "Comptabilité PGI Expert")
    'End If
    'If hWnd = 0 Then
    '     hWnd = FindWindow(vbNullString, "Comptabilité S5")
    'End If
    'If hWnd = 0 And icc = 1 Then
    '  OkConnect = False
    '  Connecte = False
    '  Exit Function
    'End If
    ' fin ajout me
 
     ' ajout me pour version 2006
    hWnd = FindWindow(vbNullString, "Comptabilité")
    If hWnd = 0 And icc = 1 Then
      OkConnect = False
      Connecte = False
      Exit Function
    End If
    ' fin ajout me
 
    On Error GoTo PasConnecte
      Set V = CreateObject("Halley.HalleyWindow")
      CodeSoc = V.GetCodeSociete
      If InStr(CodeSoc, "#Erreur") <> 0 Then
        OkConnect = False
        Connecte = False
      End If
End If
OkConnect = True
Connecte = True
Exit Function
PasConnecte:
   OkConnect = False
   Connecte = False
End Function
'Se déconnecter, puis se reconnecter à la compta
Sub ReConnecte()
If OkConnect Then
    Set V = Nothing
    CodeSoc = ""
    Set DP = Nothing
End If
OkConnect = False
Connecte (1)
End Sub
'Passage de l'écriture dans la compta par appel d'un verbe :
'V.TraiteEcrituresComptesRevision(dep, fol)
 
Function sGenereEcritures() As String
Dim ret, dep, fol, acpte, Nat As String
Dim i, j As Integer
 
ret = ""
'ret = "Erreur : écriture non passée !"
On Error GoTo fin
 
ReConnecte
If Not OkConnect Then
      MsgBox "Impossible de connaitre le dossier en cours dans la compta."
        GoTo fin
End If
 
'i = ActiveWorkbook.ActiveSheet.Shapes("CBJOURNAUX").ControlFormat.ListIndex
'i = Len(Range("_E_JOURNAL"))
'If i = 0 Then
'  i = ActiveWorkbook.ActiveSheet.Shapes("CBJOURNAUX").ControlFormat.ListIndex
'  If i = 0 Then
'  ret = "Sélectionner un journal"
'  GoTo fin
'  End If
' Else
'  j = ActiveWorkbook.ActiveSheet.Shapes("CBFOLIOS").ControlFormat.ListIndex
'  j = Len(Range("_E_FOLIO"))
'  If j = 0 Then
'     ret = "Sélectionner un folio"
'     GoTo fin
'  End If
'End If
'fol = ActiveWorkbook.ActiveSheet.Shapes("CBFOLIOS").ControlFormat.List(j)
'fol = Range("_E_FOLIO")
'If fol = "" Then fol = 0
'dep = Range("_E_JOURNAL")
'If dep = "" Then dep = ActiveWorkbook.ActiveSheet.Shapes("CBJOURNAUX").ControlFormat.List(i)
 
'28/07 contrôle de la nature du journal avant génération, définir nat avant
'Nat = V.GetNatureJrl(dep)
'If ((Nat <> "ANO") Or (Nat = "VEN")) And (Nat <> "") Then
 Nat = "OD"
 If ((Nat = "OD") Or (Nat = "REG")) Then
    ret = ""
 
    Else
 
   ret = "Nature du journal incorrect... Elle doit être de nature OD"
   GoTo fin
 End If
 
 
If Not V Is Nothing Then
 ret = V.TraiteEcrituresComptesRevision(dep, fol, "TRUE")
 End If
fin:
If ret <> "" Then
    If ret = "EPZ_ERRJALLIB" Then
        MsgBox "Le journal n'est pas de type libre. Les écritures sont générées à la date de la première ligne."
        ret = ""
    Else
        MsgBox ret
    End If
 sGenereEcritures = ret
End If
End Function
 
'Bouton Ecriture
Sub EcritureMaxi()
Dim irow As Integer, icol As Integer, prow As Integer, drow As Integer
Dim cel As Range, i As Long, dl As Long, j As Long
Dim adate As String
Dim xdevise As String, xdate As String
Dim smessage As String
Dim idebit As Currency, icredit As Currency
 
    idebit = 0
    icredit = 0
    smessage = ""
    nomfeuille = ActiveSheet.Name
    nomfichier = ActiveWorkbook.Name
    nomfeuil = Sheets(2).Name
    Sheets(nomfeuille).Activate
    Sheets(nomfeuille).Select
    With Sheets(nomfeuil)
    i = 0
    dl = .Range("a" & Rows.Count).End(xlUp).Row
    For i = 1 To dl
        Sheets(nomfeuil).Cells(i, 105).Value = Sheets(nomfeuil).Cells(i, 2).Value
        Sheets(nomfeuil).Cells(i, 106).Value = Sheets(nomfeuil).Cells(i, 4).Value
        Sheets(nomfeuil).Cells(i, 107).Value = Sheets(nomfeuil).Cells(i, 6).Value
        Sheets(nomfeuil).Cells(i, 108).Value = Sheets(nomfeuil).Cells(i, 7).Value
        Sheets(nomfeuil).Cells(i, 109).Value = Sheets(nomfeuil).Cells(i, 8).Value
        Sheets(nomfeuil).Cells(i, 110).Value = Sheets(nomfeuil).Cells(i, 15).Value
        Sheets(nomfeuil).Cells(i, 113).Value = Sheets(nomfeuil).Cells(i, 75).Value
        Sheets(nomfeuil).Cells(i, 114).Value = Sheets(nomfeuil).Cells(i, 48).Value
        If Sheets(nomfeuil).Cells(i, 11).Value = "C" Then
            Sheets(nomfeuil).Cells(i, 112).Value = Sheets(nomfeuil).Cells(i, 12).Value
        Else
            Sheets(nomfeuil).Cells(i, 111).Value = Sheets(nomfeuil).Cells(i, 12).Value
        End If
    Next
    j = i
    Columns("DA:DA").Select
    ActiveWorkbook.Names.Add Name:="E_DATECOMPTABLE", RefersToR1C1:="=Ecriture!C105"
    Columns("DB:DB").Select
    ActiveWorkbook.Names.Add Name:="E_GENERAL", RefersToR1C1:="=Ecriture!C106"
    Columns("DC:DC").Select
    ActiveWorkbook.Names.Add Name:="E_AUXILIAIRE", RefersToR1C1:="=Ecriture!C107"
    Columns("DD:DD").Select
    ActiveWorkbook.Names.Add Name:="E_REFINTERNE", RefersToR1C1:="=Ecriture!C108"
    Columns("DE:DE").Select
    ActiveWorkbook.Names.Add Name:="E_LIBELLE", RefersToR1C1:="=Ecriture!C109"
    Columns("DF:DF").Select
    ActiveWorkbook.Names.Add Name:="E_DEVISE", RefersToR1C1:="=Ecriture!C110"
    Columns("DG:DG").Select
    ActiveWorkbook.Names.Add Name:="E_DEBIT", RefersToR1C1:="=Ecriture!C111"
    Columns("DH:DH").Select
    ActiveWorkbook.Names.Add Name:="E_CREDIT", RefersToR1C1:="=Ecriture!C112"
    Columns("DI:DI").Select
    ActiveWorkbook.Names.Add Name:="E_TABLE0", RefersToR1C1:="=Ecriture!C113"
    Columns("DJ:DJ").Select
    ActiveWorkbook.Names.Add Name:="E_LIBRETEXTE0", RefersToR1C1:="=Ecriture!C114"
    End With
 
   'If Range("MoisMaxi") = 0 Then
   ' smessage = "Vous devez saisir le mois..."
   ' GoTo fin
   'End If
 
  'If Range("AnMaxi") = 0 Then
  ' smessage = "Vous devez saisir l'année..."
  ' GoTo fin
  'End If
 
  'If Range("_E_JOURNAL") = "" Then
  ' smessage = "Vous devez saisir un code journal..."
  ' GoTo fin
  'End If
 
'If Range("_E_CTRL_ALPHA") <> 0 Then
'   smessage = "Des comptes utilisés ne sont d'une structure cohérente (alphanumériques...)"
'   GoTo fin
'  End If
 
 
  'If Range("_E_TOTALG") <> 0 Then
  ' smessage = "Ecriture déséquilibrée."
  ' If Range("_E_CTRL_JOUR") <> 0 Then
  '     smessage = "Ecriture déséquilibrée, il manque le jour sur certaines lignes."
  ' End If
 
  ' If Range("_E_CTRL_CPTE") <> 0 Then
  '     smessage = "Ecriture déséquilibrée, il manque un compte en divers."
  ' End If
 
  ' GoTo fin
  'End If
 
   ActiveSheet.Unprotect
   Application.ScreenUpdating = False
   'Sheets("Feuil1").Activate
   'Application.Goto reference:=Range("_E_TOTALG"), Scroll:=True
   'adate = ActiveSheet.Range("_E_TOTALG").Offset(0, -3)
 
   xdevise = ""
   irow = 12
   icol = 39
'Colonne cpte général débit ou crédit
   'Application.Goto reference:=Range("_E_CPT_GEN"), Scroll:=True
   'For Each cel In Range("_E_CPT_GEN").Cells
   '      If (Len(cel) > 0) Or (Len(cel.Offset(0, 1)) > 0) Then
   '         If (Len(cel.Offset(0, -1)) > 0 Or Range("JourUnique") <> "") And ((cel.Offset(0, 2)) + (cel.Offset(0, 3)) <> 0) Then
   '            If irow = 12 Then
   '               Cells(irow, icol).Activate
   '               Cells(irow, icol + 1).Value = "----------" 'date
   '               Cells(irow, icol + 2).Value = "-------------------" 'général
   '               Cells(irow, icol + 3).Value = "-------------------" 'auxiliaire
   '               Cells(irow, icol + 4).Value = "------------------------------------" 'référence
   '               Cells(irow, icol + 5).Value = "-----------------------------------------------------" 'libellé
   '               Cells(irow, icol + 6).Value = "----------" 'devise
   '               Cells(irow, icol + 7).Value = "---------------------------" 'débit
   '               Cells(irow, icol + 8).Value = "---------------------------" 'crédit
   '               Cells(irow, icol + 9).Value = "---------------------------" 'section
   '               Cells(irow, icol + 10).Value = "----------------------------------------------------" 'ventilation type
   '               irow = irow + 1
   '            End If
   '            Cells(irow, icol).Activate
   '            xjour = cel.Offset(0, -1)
   '
   '            If Range("JourUnique") <> "" Then
   '               xjour = Range("JourUnique")
   '            End If
   '
   '            If Len(xjour) = 1 Then
   '               xjour = "0" & xjour
   '            End If
   '            xdate = xjour & "/" & Range("MOISMAXI") & "/" & Range("ANMAXI")
   '            If IsDate(xdate) = False Then
   '               smessage = "Date incorrecte " & xdate & "  ( " & cel.Offset(0, -1).AddressLocal & " )"
   '               GoTo Traitement
   '            End If
   '
   '            Cells(irow, icol + 1).NumberFormat = "@"
   '            'xdate = cel.Offset(0, -1) & "/" & Range("MOISMAXI") & "/" & Range("ANMAXI")
   '            Cells(irow, icol + 1).FormulaR1C1 = xdate 'jour
   '            Cells(irow, icol + 2).FormulaR1C1 = cel.Offset(0, 10) 'cpte général
   '            Cells(irow, icol + 3).FormulaR1C1 = cel.Offset(0, 11) 'cpte auxiliaire
   '            Cells(irow, icol + 4).FormulaR1C1 = cel.Offset(0, 4) 'référence
   '            Cells(irow, icol + 5).FormulaR1C1 = cel.Offset(0, 5) 'libellé
   '            If cel.Offset(0, 5) = "" Then Cells(irow, icol + 5).FormulaR1C1 = "LIBELLE"
   '               Cells(irow, icol + 6).FormulaR1C1 = xdevise 'devise
   '               'Traitement des montants négatifs
   '               If cel.Offset(0, 2) < 0 Then
   '                  Cells(irow, icol + 8).Value = -(cel.Offset(0, 2)) '- au crédit
   '                  Else
   '                  If cel.Offset(0, 2) > 0 Then
   '                     Cells(irow, icol + 7).Value = cel.Offset(0, 2) 'débit
   '                  End If
   '               End If
   '
   '               If cel.Offset(0, 3) < 0 Then
   '                  Cells(irow, icol + 7).Value = -(cel.Offset(0, 3)) '- au débit
   '                  Else
   '                  If cel.Offset(0, 3) > 0 Then
   '                     Cells(irow, icol + 8).Value = cel.Offset(0, 3) 'crédit
   '                  End If
   '               End If
   '
   '            idebit = idebit + cel.Offset(0, 2)
   '            icredit = icredit + cel.Offset(0, 3)
   '            Cells(irow, icol + 9).Value = cel.Offset(0, 7) 'section
   '            Cells(irow, icol + 10).Value = cel.Offset(0, 8) 'ventilation type
   '
   '            irow = irow + 1
   '
   '         End If
   '
   '      End If
   'Next cel
 
   anom = "Libre"
   'Cells(irow, icol).Activate
   'Cells(irow, icol).Value = "¤"
   'Cells(irow, icol + 1).Value = "----------"
   'Cells(irow, icol + 2).Value = "-------------------"
   'Cells(irow, icol + 3).Value = "-------------------"
   'Cells(irow, icol + 4).Value = "------------------------------------"
   'Cells(irow, icol + 5).Value = "-----------------------------------------------------"
   'Cells(irow, icol + 6).Value = "----------"
   'Cells(irow, icol + 7).Value = "---------------------------"
   'Cells(irow, icol + 8).Value = "---------------------------"
    icol = 105
    irow = dl
    Sheets(nomfeuil).Select
Traitement:
   ActiveWorkbook.Names.Add Name:="_OD_" & anom, RefersToR1C1:="=" + afeuille + "!R" + CStr(1) + _
                                                               "C" + CStr(icol) + _
                                                               ":R" + CStr(irow) + _
                                                               "C" + CStr(icol + 10)
 
Application.Goto reference:="_OD_" & anom
With Selection.Font
    .Name = "Arial"
    .FontStyle = "Normal"
    .Size = 10
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
End With
 
Selection.Copy
 
 
sRet = sGenereEcritures
 
 
If (Len(sRet) = 0) And OkConnect Then
    MsgBox " L'ECRITURE A ETE COMPTABILISEE !"
    Application.Goto reference:="_OD_" & anom
    Selection.delete Shift:=xlUp
    Application.CutCopyMode = False
Else
    MsgBox "PROBLEME : L'ECRITURE N'A PAS ETE COMPTABILISEE !"
    Application.Goto reference:="_OD_" & anom
    Selection.delete Shift:=xlUp
    Application.CutCopyMode = False
End If
 
fin:
    'ActiveSheet.Protect
    If Len(smessage) > 0 Then
      MsgBox (smessage)
    End If
    Application.Goto reference:=ActiveSheet.Range("A1"), Scroll:=True
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
 
 
Sub ActiveAnal()
'
' Macro1 Macro
' Macro enregistrée le 29/07/2004 par Jallaguier
'
If Range("EtatAnalytique") = "Pas de saisie de l'analytique" Then
    'Procédure d'activation de l'analytique
   Columns("I:L").Select
   Selection.EntireColumn.Hidden = False
   ActiveSheet.Shapes("Button 10").Select
   Selection.Characters.Text = "Désactivation de l'analytique"
   With Selection.Characters(Start:=1, Length:=32).Font
        .Name = "Tahoma"
        .FontStyle = "Gras Italique"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
   Range("EtatAnalytique") = "Saisie analytique activée"
Else
 
    'Procédure pour masquer les colonnes analytiques
    Columns("J:K").Select
    Selection.EntireColumn.Hidden = True
    ActiveWindow.DisplayHeadings = False
    ActiveSheet.Shapes("Button 10").Select
    Selection.Characters.Text = "Activation de l'analytique"
    With Selection.Characters(Start:=1, Length:=32).Font
        .Name = "Tahoma"
        .FontStyle = "Gras Italique"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    Range("EtatAnalytique") = "Pas de saisie de l'analytique"
End If
    Range("B12").Select
 
End Sub

La majeur partie des commentaires c'est le code original que j'ai supprimer car ce n'était pas les bonnes références ou autres.
Si quelqu'un voit d'ou pourrait venir mon probleme....
D'avance merci.