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
   | Sub Sommaire()
 
With ActiveSheet.QueryTables.Add(Connection:= _
  "TEXT;Disque Dur:Users:francois:Desktop:exemple en word.doc", Destination:= _
    Range("A1"))
  'Tu devras remplacer par ton chemin d'accès
  .Name = "exemple en word"
  .FieldNames = True
  .RowNumbers = False
  .FillAdjacentFormulas = False
  .RefreshOnFileOpen = False
  .BackgroundQuery = True
  .RefreshStyle = xlOverwriteCells
  .SavePassword = False
  .SaveData = True
  .AdjustColumnWidth = True
  .TextFilePromptOnRefresh = False
  .TextFilePlatform = xlWindows
  .TextFileStartRow = 1
  .TextFileParseType = xlDelimited
  .TextFileTextQualifier = xlTextQualifierDoubleQuote
  .TextFileConsecutiveDelimiter = False
  .TextFileTabDelimiter = True
  .TextFileSemicolonDelimiter = False
  .TextFileCommaDelimiter = False
  .TextFileSpaceDelimiter = False
  .TextFileOtherDelimiter = "["
  .TextFileColumnDataTypes = Array(1, 1)
  .Refresh BackgroundQuery:=False
  .UseListObject = False
End With
i = 1
Do Until Left(Cells(i, 1), 6) Like "MSWord"
  If Right(Cells(i, 2), 1) <> "]" Then
    Cells(i, 2).EntireRow.Delete
  Else
    i = i + 1
  End If
Loop
Cells(i, 1).EntireRow.Delete
Cells(1, 1).Select
Position = InStr(1, Selection, 1, 1) - 1
Selection.Replace What:=Left(Cells(1, 1), Position), Replacement:="", LookAt:=xlPart, _
  SearchOrder:=xlByColumns, MatchCase:=True
Columns("B:B").Select
Selection.Replace What:="]", Replacement:="\", LookAt:=xlPart, _
  SearchOrder:=xlByColumns, MatchCase:=True
Columns("A:A").Cut Destination:=Columns("C:C")
Columns("A:A").Delete Shift:=xlToLeft
Columns("A:A").EntireColumn.AutoFit
Columns("A:A").HorizontalAlignment = xlRight
Range("A1").Select
End Sub | 
Partager