Import de données d'un fichier texte vers Excel
Bonjour à tous,
J'essaye de faire une macro pour recopier les données qui se trouve dans un fichier ".csv" pour les copier dans un fichier Excel.
En faisant la macro via l'enregistreur ça a marcher, mais quand je colle le code dans ma Macro il bloque sur :
Refresh BackgroundQuery:=False.
Je ne sais pas pourquoi.
Est-ce que vous pouvez m'aider SVP.
Voici mon code :
Sub Macro2()
'
' Macro2 Macro
'
Sheets("Import").Select
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:="TEXT;chemin", Destination:=Range("$A$1"))
'.CommandType = 0
.Name = "nom"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2, 2, 2, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub