Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
OE OE is offline
external usenet poster
 
Posts: 8
Default import fixed width text file

The import specification works as intended when used manually (via FileGet
External Data....). But when the spec is used within a Routine the data
imports into one column only. I think the error is in the syntax of
TransferText.

DoCmd.TransferText acImportDelim, "Tagged Transactions Import
Specification", _
"RawDataImport", TextFile2Open

The Help file says "...For a fixed-width text file, you must either specify
an argument or ... " in relation to the specification. Any help much
appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default import fixed width text file

OE,

For importing fixed width data with a macro, you can use the OpenText
method:

Workbooks.OpenText Filename:= _
"C:\Documents and Settings\Examples\Test.prn", _
Origin:=437, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array( _
Array(0, 1), Array(3, 1), Array(5, 1), Array(8, 1), Array(11, 1),
Array(14, 1)), _
TrailingMinusNumbers:=True

Or you can use QueryTables:

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\Examples\Test.prn" _
, Destination:=Range("A1"))
.Name = "Test"
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileFixedColumnWidths = Array(3, 2, 3, 3, 3)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With

I'm not familiar with the TransferText method, so I can't help you there.

HTH,
Bernie
MS Excel MVP


"OE" wrote in message
...
The import specification works as intended when used manually (via

FileGet
External Data....). But when the spec is used within a Routine the data
imports into one column only. I think the error is in the syntax of
TransferText.

DoCmd.TransferText acImportDelim, "Tagged Transactions Import
Specification", _
"RawDataImport", TextFile2Open

The Help file says "...For a fixed-width text file, you must either

specify
an argument or ... " in relation to the specification. Any help much
appreciated.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fixed Width Text Import Settings Bryan Excel Discussion (Misc queries) 4 July 8th 08 12:15 AM
Automate the Text Import Wizard (Fixed Width) Yagnesh Excel Worksheet Functions 5 August 25th 05 08:08 PM
Best way to import fixed-width delimited text files into an array? KR Excel Programming 1 March 3rd 05 02:40 PM
Automatically Parsing Fixed-width Text Import Bill[_29_] Excel Programming 3 October 5th 04 06:11 AM
Import *.asc file into excel fixed width Hartsell Excel Programming 1 February 24th 04 08:15 AM


All times are GMT +1. The time now is 04:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"