April 2006
Beginner
1114 pages
98h 16m
English
querytable.TextFileFixedColumnWidths[= setting]
Sets or returns an array of integers that correspond to the widths of the columns in the text file that you are importing into the specified query table. The following code imports text from a sample file and places the characters in each row of the active worksheet as follows:
The first five characters are placed in the first column.
The next four characters are placed in the second column.
The remaining characters are placed in the third column:
Dim strCnn As String
Dim qt As QueryTable
strCnn = "TEXT;C:\My Documents\qtsample.txt"
Set qt = ActiveSheet.QueryTables.Add(Connection:=strCnn,& _
Destination:=ActiveSheet.Range("A1"))
With qt
.TextFileParseType = xlFixedWidth
.TextFileFixedColumnWidths = Array(5, 4)
.Refresh
End WithRead now
Unlock full access