Strange problem when reading from a text file

Thomas B

New Member
Joined
Jul 10, 2003
Messages
36
Dear all,
I have a macro that reads from a text file, but it skips trailing '1'!
Have tried a lot with the original macro, and boiled it down to the very basic here. Tried a lot with the format specifiers, but no luck.
When playing around with the context of test.txt, it seems like VBA is treating '1' as a seperator

Any clues?

Thanks Thomas B.

text file : test.txt

41
42


macro
Sub ReadPrjFileNew()
FileName = "TEST.txt"
CompleteFileName = "TEXT;" & FileName

' Start with clearing the whole lot
Cells.Select
Selection.ClearContents
Selection.FormatConditions.Delete
Selection.ColumnWidth = 10
Selection.Font.FontStyle = "normal"
Selection.Interior.ColorIndex = xlNone

With ActiveSheet.QueryTables.Add(Connection:= _
CompleteFileName, Destination:=Range("A1") _
)
.Name = FileName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
'.TextFileTextQualifier = xlTextQualifierNone
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileOtherDelimiter = xlTextQualifierDoubleQuote
.TextFileColumnDataTypes = Array(xlTextFormat)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Remove this line:
Code:
.TextFileOtherDelimiter = xlTextQualifierDoubleQuote

xlTextQualifierDoubleQuote is a constant that has the value 1.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,738
Members
448,988
Latest member
BB_Unlv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top