polpy2
08-01-2008, 12:41
Ciao a tutti,
sono nuovo di questo forum, spero di aver azzeccato il topic per inserire questo post!!!
Ho un problema nella realizzazione di una macro excel che importi i dati contenuti in un file di testo letto da una dialog box
Fino ad ora ho capito che con
fileToOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt")
apro un file di testo
e con
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\testo_prova2.txt", _
Destination:=Range("$T$7"))
.Name = "testo_prova2_14"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
importo il file "testo_prova2.txt" in una casella di testo.
Il problema è collegare le due azioni:
come faccio a dire all'"Add connection" che il file da aprire è quello inserito in "fileToOpen" e non è sempre "testo_prova2.txt"?
Grazie a tutti per il tuo aiuto.
Ciao
sono nuovo di questo forum, spero di aver azzeccato il topic per inserire questo post!!!
Ho un problema nella realizzazione di una macro excel che importi i dati contenuti in un file di testo letto da una dialog box
Fino ad ora ho capito che con
fileToOpen = Application.GetOpenFilename("Text Files (*.txt), *.txt")
apro un file di testo
e con
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\testo_prova2.txt", _
Destination:=Range("$T$7"))
.Name = "testo_prova2_14"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
importo il file "testo_prova2.txt" in una casella di testo.
Il problema è collegare le due azioni:
come faccio a dire all'"Add connection" che il file da aprire è quello inserito in "fileToOpen" e non è sempre "testo_prova2.txt"?
Grazie a tutti per il tuo aiuto.
Ciao