Results 1 to 2 of 2

Thread: Loosing Leading Zeros While opening a deliminated file that contains Number Columns

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    2

    Post 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

  2. #2
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    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
  •  



Click Here to Expand Forum to Full Width