Sub Sommaire()
' Sommaire Macro
' Macro enregistrée le 7/01/2009 par Gruick
[COLOR="SeaGreen"]'Partie fabriquée en enregistrement automatique[/COLOR]
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;Disque Dur:Users:francois:Desktop:exemple en word.doc", Destination:= _
Range("A1"))
[COLOR="SeaGreen"] 'Tu devras remplacer par ton chemin d'accès[/COLOR]
.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
[COLOR="SeaGreen"]'inspecte les lignes jusqu'a ce que tu trouves le mot MSWord en
'première colonne. Si en 2e colonne il y a un ], la conserver
'sinon, détruire la ligne[/COLOR]
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
[COLOR="SeaGreen"]'Première cellule à inspecter, détruire tout ce qu'il y a
'avant le 1.[/COLOR]
Cells(1, 1).Select
Position = InStr(1, Selection, 1, 1) - 1 'Recherche la position du 1 dans la cellule A1
Selection.Replace What:=Left(Cells(1, 1), Position), Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=True
[COLOR="SeaGreen"]'Remplace en colonne B les ] par rien[/COLOR]
Columns("B:B").Select
Selection.Replace What:="]", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=True
[COLOR="rgb(46, 139, 87)"]'Permutation de la colonne A en C et destruction le la colonne A devenue vide[/COLOR]
Columns("A:A").Cut Destination:=Columns("C:C")
Columns("A:A").Delete Shift:=xlToLeft
[COLOR="SeaGreen"]'Formatage et Présenation à droite[/COLOR]
Columns("A:A").EntireColumn.AutoFit
Columns("A:A").HorizontalAlignment = xlRight
Range("A1").Select
End Sub