LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
 
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
IMPORTING PC-DOS PLAIN TEXT FILES WITH LEADING SPACES Robert1998 Excel Discussion (Misc queries) 4 October 22nd 08 06:16 AM
Import a txt file with text fields that have meaningful leading sp Muehe Excel Discussion (Misc queries) 2 April 3rd 08 11:48 PM
webquery loses format of leading zero and to scientific Glen: Webquery format Excel Programming 3 August 11th 05 04:40 AM
number of fields exceeds 256 when importing from a dbf file Chris Excel Discussion (Misc queries) 5 July 14th 05 09:49 PM


All times are GMT +1. The time now is 09:11 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"