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.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

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
 

Forum statistics

Threads
1,141,139
Messages
5,704,508
Members
421,353
Latest member
jekoxien15

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
Top