Salve a tutti,
ho un problema da risolvere e non so usare le macro di excel. Ho dato un'occhiata alle altre discussioni in questo forum che proponevano problemi simili ma non sono riuscita a fare granchè.
Seguendo i suggerimenti di quelle discussioni ho registrato una macro mentre facevo le operazioni necessarie al mio scopo ed è la seguente:
Sub importaeaccoda()
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\ARCHIVIO\doc0.txt", Destination:=Range( _
"A1"))
.Name = "site0pars"
.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, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Range("A3").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\ARCHIVIO\doc1.txt", Destination:=Range( _
"A3"))
.Name = "site1pars"
.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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Mi rendo conto che non deve essere difficile perchè il file di testo ha una struttura fissa (sono 2 righe x 13 colonne) e delimitata (tab), ma la procedura deve essere ripetuta per N volte tante quanti sono i files *.txt. Immagino di dover impostare un ciclo ma non so come fare. Come dicevo sono a zero ancora con le macro
Grazie in anticipo a chi vorrà aiutarmi e spero di essere stata chiara.