Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Dropping leading zeros in character fields.

Hello Group
I am programatically creating an excel work sheet loading
the columns from fields in a Database file. The fields
in the DB are defined as character but when the spread
sheet gets created it drops the leading zeros. It assume
the data is numeric but it is not. These leading zeros
are required. Does anyone know how I can resolve this
problem.
I am using a program language called Visual RPG which is
very similar to Visual Basic.
Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Dropping leading zeros in character fields.

Open it as a text file
Suppose you have file
0001 A
0002 B
0003 C
0004 D
0005 E

separated by any delimeter. (In my example it is tab). Lets say your file is
"YourFie.txt"
then the following code will do the job:

Workbooks.OpenText Filename:="YourPath" & "\" & "YourFie.txt", _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=True, _
Semicolon:=False, _
Comma:=False, _
Space:=False, Other:=False, _
FieldInfo:=Array(Array(1, 2), Array(2, 1))

FieldInfo says first column will be of type text.

Ömer Ayzan

"Ron K" wrote in message
...
Hello Group
I am programatically creating an excel work sheet loading
the columns from fields in a Database file. The fields
in the DB are defined as character but when the spread
sheet gets created it drops the leading zeros. It assume
the data is numeric but it is not. These leading zeros
are required. Does anyone know how I can resolve this
problem.
I am using a program language called Visual RPG which is
very similar to Visual Basic.
Thanks.



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
Leading Zero dropping off after export to Excel Tina Hudson Excel Discussion (Misc queries) 3 March 30th 10 08:15 PM
How do I stop Excel from dropping leading zeros? Carl Nash Excel Discussion (Misc queries) 9 April 22nd 09 08:11 PM
Dropping Zeros Rene'' Excel Worksheet Functions 8 April 23rd 07 08:32 PM
Converting xls to CSV file - dropping leading 0s vanjohnson Excel Discussion (Misc queries) 1 July 5th 06 07:47 PM
removing leading zeros in numeric fields dingy101 Excel Discussion (Misc queries) 3 November 21st 05 03:46 AM


All times are GMT +1. The time now is 10:40 PM.

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"