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
|
Private Sub compilation_Click()
If test Then
Compil Listannex, adresseannex
End If
End Sub
------------------------------------------------
Private Sub Compil(ListX As Listbox, CheminX As Variant)
Dim nomficher As String
Dim longlist As Integer, num As Integer
D = ListX & "2"
longlist = ListX.ListCount
num = longlist - 1
While num >= 0
nomfichier = ListX.List(num, 0)
a = False
For i = 0 To D.ListCount - 1
If D.List(i, 0) = nomfichier Then a = True
Next i
If ListX.Selected(num) = True Then
If Not a Then
ChangeFileOpenDirectory (CheminX)
Selection.InsertFile nomfichier, Range:="", _
ConfirmConversions:=False, Link:=True, Attachment:=False
End If
indice = Selection.PreviousField.Index
While InStr(1, ActiveDocument.Fields(indice).Code.Text, "INCLUDETEXT", 1) = 0
indice = Selection.PreviousField.Index
Wend
Selection.MoveLeft Unit:=wdCharacter, Count:=1
End If
If a And ListX.Selected(num) = False Then
indice = Selection.PreviousField.Index
While InStr(1, ActiveDocument.Fields(indice).Code.Text, "INCLUDETEXT", 1) = 0
indice = Selection.PreviousField.Index
Wend
Selection.MoveLeft Unit:=wdCharacter, Count:=1
End If
num = num - 1
DoEvents
Wend
a = False
For i = 0 To Listannex2.ListCount - 1
If Listannex2.List(i, 0) = "00-1.doc" Then a = True
Next i
If Not a Then
ChangeFileOpenDirectory (cheminannex.Text)
Selection.InsertFile FileName:="00-1.doc", Range:="", _
ConfirmConversions:=False, Link:=True, Attachment:=False
DoEvents
End If
indice = Selection.PreviousField.Index
While InStr(1, ActiveDocument.Fields(indice).Code.Text, "INCLUDETEXT", 1) = 0
indice = Selection.PreviousField.Index
Wend
Selection.MoveLeft Unit:=wdCharacter, Count:=1
DoEvents
End Sub |