View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Sheeloo[_3_] Sheeloo[_3_] is offline
external usenet poster
 
Posts: 1,805
Default IMPORTING PC-DOS PLAIN TEXT FILES WITH LEADING SPACES

TextFileTabDelimiter = True tells me that TAB is taken as the separator...

..TextFileColumnDataTypes = Array(2) indicates that first field is imported
as TEXT and others as General..

Are you sure there are spaces in the text file. If it has TABs only then
they will not be imported...

If possible mail the text file to me...
my id is to_sheeloo
add @hotmail.com to it to get the address
Also let me know the Excel version...



"Robert1998" wrote:

This is the text file...

1 UI_NOM Character 35
2 UI_ADR Character 35
3 UI_VIL Character 35
4 UI_COD Character 35
5 UI_TL1 Character 10
6 UI_TL2 Character 10
7 UI_FAX Character 10

This is the macro I recorded using the wizard....

Range("C13").Select
With
ActiveSheet.QueryTables.Add(Connection:="TEXT;S:\A SEbeta\STRUC.TXT", _
Destination:=Range("$C$13"))
.Name = "STRUC_1"
.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(2)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

I hope it makes sense. (I am a new)

Thank you




"Sheeloo" wrote:

I just tested with the four line file give below and spaces were preserved..
(nos added for readability, not part of the file)
1: Text1,09/10/2008, Text2,12345,09/10/2008
2: Text2,09/10/2008, Text2,12345,09/10/2008
3: Text3,12/15/2008, Text2,12345,09/10/2008
4:Text4,09/10/2008,Text2,12345,09/10/2008

Can you desribe the steps you are taking to import...
if possible paste a line of data...
"Robert1998" wrote:

Hello,
I am having trouble importing plain MS-DOS text files. Leading spaces on
lines get removed in Excel . How can I prevent the removal of the leading
spaces?

Example ... ORIGINAL TEXT LINE = "_____Thank you"
IMPORTED in excel = "Thank you"
The import wizard shows the leading spaces correctly.
Font used is COURRIER NEW (monospace I believe)
Cell format is TEXT.

Thank you