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
| '---------------------------------------------------------
Option Explicit
Dim BB$()
Dim r As Boolean
Dim fName As String
Sub OuvreFich()
Dim B$(), Arr()
Dim Reponse As Variant, Canal As Variant
Dim Item
Dim A$
Dim i As Byte, j As Byte, k As Byte, LastLg As Long, X As Long
Dim wkPA As Workbook, wkJCW As Workbook, wkMSK As Workbook
'Tableau des XAC
Arr = Array("12", "15", "70", "33", "62")
fName = "TPC " ' Nom du fichier sous la forme : "TPC*.xls"
Application.ScreenUpdating = False
Application.EnableEvents = False
'On Error Resume Next
Reponse = Application.GetOpenFilename _
("All Files (*.*),*.*")
If Reponse = False Then Exit Sub
Canal = FreeFile
Open Reponse For Input As #Canal
ReDim BB$(4, 2) ' 5 lignes et 3 colonnes
Do While Not EOF(Canal)
Line Input #Canal, A$
If Len(Trim(A$)) > 0 Then '-- Si la ligne est non vide
If InStr(1, A$, " OAC") > 0 Then
Line Input #Canal, A$
Line Input #Canal, A$
Line Input #Canal, A$
X = 0
Do While InStr(1, A$, "END") = 0
i = 0: j = 0
If Len(Mid(Trim(A$), 1, 2)) > 0 Then
If Not IsError(Application.Match(Mid(Trim(A$), 1, 2), Arr, 0)) Then
B$ = Split(Trim(A$), " ")
'-- Eliminer les vides du tableau B$
For Each Item In B$
If Len(Item) > 0 And Item <> "S" And j <= 2 Then
BB$(X, j) = B$(i)
j = j + 1
End If
i = i + 1
Next Item
X = X + 1
End If
End If
Line Input #Canal, A$
Loop
End If
End If
Loop
For k = LBound(BB$) To UBound(BB$)
Select Case BB$(k, 0)
Case "12"
Call OpenWriteF("PA", 0)
Case "70"
Call OpenWriteF("JCW", 2, False)
Case "33"
Call OpenWriteF("MSK", 3)
End Select
Next k
'On Error GoTo 0
End Sub
'------------------------------------------
Sub OpenWriteF(f As String, L As Byte, Optional r As Boolean = True)
Workbooks.Open fName & f & ".xls"
With Sheets("feuil2")
.[E22] = .[F22]: .[F22] = BB$(L, 1): .[G22] = .[H22]: .[H22] = BB$(L, 2)
If r Then
.[E25] = .[F25]: .[F25] = BB$(L + 1, 1): .[G25] = .[H25]: .[H25] = BB$(L + 1, 2):
End If
End With
End Sub |
Partager