Microsoft Knowledge Base Email Alertz

(835718) - Describes an issue that occurs when you use a macro to convert a CSV text file into an Excel 2002 workbook.The format of dates are incorrectly converted.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 835718 - Last Review: October 9, 2011 - Revision: 5.0

Date format is not correct when you convert a CSV text file in Excel 2002 by using a VBA macro

Important This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:
256986  (http://kbalertz.com/Feedback.aspx?kbNumber=256986/ ) Description of the Microsoft Windows Registry

On This Page

SYMPTOMS

When you use a Microsoft Visual Basic for Applications (VBA) macro to convert a Comma-Separated Values (CSV) text file into a Microsoft Excel 2002 workbook (*.xls), the format of dates that are converted into your Excel 2002 workbook may not be correct.

For example, in your CSV file, dates may be in the format of:
dd/mm/yyyy
When you run the following macro to convert your CSV text file into Excel, dates may be converted in the following mm/dd/yyyy format:
Sub test()

   Workbooks.OpenText Filename:="C:\Test1.csv", DataType:=xlDelimited, _
      TextQualifier:=xlTextQualifierNone, FieldInfo:=Array(1, 4)
	
End Sub

RESOLUTION

How to obtain the hotfix

This issue is fixed in the Excel 2002 Hotfix Package . For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
829348  (http://kbalertz.com/Feedback.aspx?kbNumber=829348/ ) Excel 2002 post-Service Pack 3 hotfix package: May 6, 2004

After you install this hotfix, follow the steps that are listed in the "More Information" section of this article to set the VBAAlwaysLoadUS registry key and to activate the hotfix.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To work around this problem, add the <local:=true> parameter to your VBA macro as in the following example:
Sub test()
	
   Workbooks.OpenText Filename:="C:\Test1.csv", DataType:=xlDelimited, _
      TextQualifier:=xlTextQualifierNone, FieldInfo:=Array(1, 4), Local:=True
	
End Sub

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section of this article.

MORE INFORMATION

Warning If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.
To activate this hotfix, follow these steps:
  1. Quit Excel 2002.
  2. Click Start, and then click Run.
  3. In the Open box, type regedit, and then click OK.
  4. Locate, and then click to select the following registry key:
    HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Excel\Options
  5. After you select the key that is specified in step 4, point to New on the Edit menu, and then click DWORD Value.
  6. Type VBAAlwaysLoadUS, and then press ENTER.
  7. Right-click VBAAlwaysLoadUS, and then click Modify.
  8. In the Value data box, type 00000000, and then click OK.
  9. On the File menu, click Exit to quit Registry Editor.

APPLIES TO
  • Microsoft Excel 2002 Standard Edition
Keywords: 
kbqfe kbhotfixserver kbofficexppostsp3fix kbfix kbbug KB835718
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Simon Reported as Irrelevant  
Written: 9/5/2004 11:48 AM
Exactly the same problem exists in Excel 2000, only in Excel 2000 this workaround doesn't work because the "Local:=True" part causes a compiler error "Named arugment not found". So does anybody know a workaround that does work in Excel 2000?

Greg Reported as Irrelevant  
Written: 9/21/2004 2:21 AM
Yes, this does work for .txt files and also xls formatted data from other programs.