Text Import Wizard - Text Qualifier?

LoreCoder

New Member
Joined
Sep 21, 2006
Messages
2
I am trying to create text files that are as close to completely formatted for EXCEL as I can get. I'm creating these files on a UNIX/BBx-Basic machine. I'd like to be able to embed something in the file to tell it that the field is TEXT instead of GENERAL.

I thought that the Text Qualifier might enable this. I must be wrong. So, what is this for?

Is there a way to create a file the way I want?

I need this so the users don't have to go to each of the many columns and specify TEXT. The file names are always different so I don't know how to make a macro for this. Obviously, EXCEL is not my specialty!

Thank you.
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Dufus

Board Regular
Joined
Aug 19, 2006
Messages
176
LoreCoder,

If you record the import, you will see the way VBA recognizes a field as text. Then you can post the code and I'm sure someone will help you clean it up.

Dufus
 

LoreCoder

New Member
Joined
Sep 21, 2006
Messages
2
I recorded the import. I see how it labels each field in an array. Can you execute a macro in the middle of an import? It doesn't appear that you can. Is there an ascii code I can place in the file as I create it to tell Excel to treat the field as Text?

Thank you.
 

Dufus

Board Regular
Joined
Aug 19, 2006
Messages
176
In this sample, Array(0,2), the ",2" tells Excel whether or not the data is text. In the worksheet you import the data into, you may have formatting of the columns and rows also. This formatting can also affect the formatting the data ultimately assumes. To avoid all problems for data imports, I usually specify the data type in the ",2" part of the Data Import Wizard and make sure the destination range matches.

Code:
Workbooks.OpenText Filename:="C:\DOWNLOAD.TXT", Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth,  _
FieldInfo:=Array(Array(0, 2), Array(15, 2))

Dufus
 

Watch MrExcel Video

Forum statistics

Threads
1,109,028
Messages
5,526,332
Members
409,696
Latest member
EERS

This Week's Hot Topics

Top