-
Apr 1st, 2015, 01:43 PM
#1
Thread Starter
New Member
Loosing Leading Zeros While opening a deliminated file that contains Number Columns
Dim sPath As String
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
sPath = "C:\File.dat"
Call xlApp.Workbooks.OpenText(sPath, , , 1, , , , , True, , True, "|")
With above mentioned code, I am trying to open a deliminated file (that contains number columns with leading Zeros). When file is opened in excel, all the leading Zeros are gone.
How can I tell excel not to do any formatting on values (or in other words) keep leading zeros as is.
Thanks
-
Apr 1st, 2015, 01:58 PM
#2
Re: Loosing Leading Zeros While opening a deliminated file that contains Number Colum
Numbers should typically be imported as numeric values and then formatted using the cell format property. If the number of leading zeros varies and has meaning, you can import the column as text by setting the "FieldInfo" parameter of the OpenText method. In the VBA Editor, press F1 for help and search for "OpenText".
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|