Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The format of the dates is incorrect when you use a VBA macro to convert a CSV text file in Excel 2003


Symptoms

You use a Microsoft Visual Basic for Applications (VBA) macro to convert a comma separated values (CSV) text file to a Microsoft Office Excel 2003 workbook (*.xls). However, the format of the dates that are converted in your Excel 2003 workbook is incorrect.

For example, in the CSV file, dates may be in the dd/mm/yyyy format. The dates may be converted to the mm/dd/yyyy format when you run the following macro to convert the CSV file into an Excel workbook:
Sub test()

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

↑ Back to the top


Resolution

This problem was first fixed in a hotfix that is now contained in a service pack. If you installed the latest Office 2003 service pack, you do not have to install the hotfix.

Service pack information

This problem is corrected in Office 2003 Service Pack 3. To resolve this problem, obtain the latest service pack for Office 2003. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
870924 How to obtain the latest service pack for Office 2003

After you install the service pack, follow the steps that are listed in the "How to enable the hotfix" section to set the
VBAAlwaysLoadUS
registry key and to activate the hotfix.

Hotfix information

How to obtain the hotfix

This issue is fixed in the Excel 2003 post-Service Pack 2 Hotfix Package that is dated December 8, 2005. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
911019 Description of the Excel 2003 post-Service Pack 2 hotfix package: December 8, 2005

How to enable the hotfix

Warning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall your operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk.

To enable this hotfix, follow these steps:
  1. Quit Excel 2003.
  2. Click Start, click Run, type regedit in the Open box, and then click OK.
  3. Locate and then click to select the following registry key:
    HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Options
  4. After you select the key that is specified in step 3, point to New on the Edit menu, and then click DWORD Value.
  5. Type VBAAlwaysLoadUS, and then press ENTER.
  6. Right-click VBAAlwaysLoadUS, and then click Modify.
  7. In the Value data box, type 1, and then click OK.
  8. On the File menu, click Exit to quit Registry Editor.

↑ Back to the top


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

↑ Back to the top


Status

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

This problem was first corrected in Office 2003 Service Pack 3.

↑ Back to the top


Keywords: KB911750, kbfix, kbbug, kbqfe, kbexpertiseinter, kbautomation, kbprogramming, kbvba, kboffice2003sp3fix, kbregistry

↑ Back to the top

Article Info
Article ID : 911750
Revision : 3
Created on : 10/9/2011
Published on : 10/9/2011
Exists online : False
Views : 101