View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] brettmanning24@gmail.com is offline
external usenet poster
 
Posts: 27
Default Importing Text File into Excel loses leading zero on some fields.

Hello,

Is it possible to import a txt file into Excel and keep the leading
zero's? I am using vbscript to import the text file, the text file
contains a user reference which sometimes contains a number with a
leading zero i.e. 0111. This number is imported as 111. The user
reference varies sometimes so I cannot really use a custom field i.e.
"0"#.

Below is an example of the import procedure I am using, is it possible
to specify that for example column L is displayed as text?

Range("FileOrig").FormulaR1C1 = FILEtoOPEN

Workbooks.OpenText Filename:=FILEtoOPEN, Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _
:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, _
FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1),
Array(4, 1), Array _
(5, 4), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1),
Array(10, 1), Array( _
11, 1), Array(12, 1), Array(13, 1))
Range("A1:AZ1500").Select
Selection.Copy

Thanks,

Brett