Ciao a tutti,
dovendo importare spesso dati txt o csv in un Foglio Excel 2003, utilizzo abitualmente la procedura 'Importa dati esterni'.
Ho cercato di automatizzare l'operazione creando la macro seguente, ma vorrei inserire un box di ricerca del file txt o csv da importare. Non ci riesco... è possibile?
Ecco il codice che ho creato:
- Codice: Seleziona tutto
Sub Importa_dati()
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\...\VARIA.txt.", _
Destination:=Range("A1"))
.Name = "VARIA.txt."
.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 = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "|"
.TextFileColumnDataTypes = Array(2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Grazie per l'aiuto