Excel Inserts Extra Rows In Text File

J

Jim Palmer

When I open a certain text file either with the macro listed below, o
from windows explorer, Excel inserts a blank row between each row o
data. Is there some setting that can be changed to correct this?

Any assistance would be appreciated.

Sincerely

Jim Palmer


ChDir "J:\"

Dim Filter As String
Dim Caption As String


Filter = "All Files (*.*),*.*"
Caption = "Select a File"
SelectedFile = Application.GetOpenFilename(Filter, , Caption)


Workbooks.OpenText Filename:=SelectedFile, _
Origin:=437, StartRow:=1 _
, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1)
Array(3, 1), _
Array(7, 1) _
, Array(11, 1), Array(29, 1), Array(40, 1), Array(53, 1)
Array(59, 1), _
Array(66, 1), Array( _
79, 1), Array(92, 1), Array(98, 1), Array(112, 1), Array(125
1)), _
TrailingMinusNumbers _
:=Tru
 
D

Dave Peterson

I've never seen xl insert any extra lines in a file like this.

Is there anyway you can open your text file in a real text editor and check to
see if each line ends with a carriage return/line feed pair of characters.

It sounds like you have an extra character at the end of each line that excel
reads as a new line.

Most Windows/DOS text files end with a hex 0D followed by a hex 0A.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top