File di testo

Storico discussioni

Importa txt di Apoben64
A beneficio degli utenti del forum allego la macro, oggetto della discussione di katia
, per importare in excel un file di testo composto da dati di questo tipo e separati in colonne esempio:
aaaa bbbbb cccc ddddd ffff


 
Sub Importa()
    With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\PROVA.TXT", _
        Destination:=Range("A1"))
        .Name = "PROVA"
        .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 = xlFixedWidth
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1)' numero delle colonne 
        .TextFileFixedColumnWidths = Array(7, 13)' larghezza colonne
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
End Sub

di Mauro
Fantastico luca adesso me la scarico e la studio!
ad ogni modo anche il files che avevo allegato contiene parecchi esempi utili. tutto sta a studiarseli un po'.
ciao

Cognolato Studio © 2005