Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Workbooks.Open incorrectly formating date column

Hi,
I have a CSV file and one of the columns is date in the format of
DD/MM/YYYY. If I open this manually the date column is fine. If however I
open the same file in code...
Workbooks.Open Filename:="Log.csv"
Excel converts the dates where the first number is less than 13 to an
american type date. I.e. 03/10/2004 becomes 10/03/2004.

How can I stop this from happening???
Ta
Paul

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Workbooks.Open incorrectly formating date column

CSV file format and Excel are notorious
if your regional settings are anything but USenglish :(


Step 1 .. RENAME the thing to TXT.


DO you have Excel XP or 2003?

Check out the LOCAL argument in
OpenText and
SaveAS methods

(again: ONLY for excel XP / 2003)
it appears to have been added as an afterthought..
and is hardly documented in VBA help.



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"?B?UGF1bA==?=" wrote:

Hi,
I have a CSV file and one of the columns is date in the format of
DD/MM/YYYY. If I open this manually the date column is fine. If
however I open the same file in code...
Workbooks.Open Filename:="Log.csv"
Excel converts the dates where the first number is less than 13 to an
american type date. I.e. 03/10/2004 becomes 10/03/2004.

How can I stop this from happening???
Ta
Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Workbooks.Open incorrectly formating date column

Hi Paul,

I have a CSV file and one of the columns is date in the format of
DD/MM/YYYY. If I open this manually the date column is fine. If however I
open the same file in code...
Workbooks.Open Filename:="Log.csv"
Excel converts the dates where the first number is less than 13 to an
american type date. I.e. 03/10/2004 becomes 10/03/2004.

How can I stop this from happening???


Use Workbooks.OpenText, which takes additional parameters to specify the
DMY/MDY order of dates. You might have to rename the file's extension from
csv to something else though, as Excel sometimes treats files with a 'csv'
extenions in a 'special' way.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Workbooks.Open incorrectly formating date column

Rename the workbook with a .txt extension.

Turn on the macro recorder

Manually Open the workbook using File=Open

Walk through the text import wizard. In the 3rd dialog, specify the date
order for that column

Complete opening the file and turn off the macro recorder.

Now modify the macro to rename the file with a .txt extension, open it using
the recorded opentext method.

Whatever else you need.

--
Regards,
Tom Ogilvy

"Paul" wrote in message
...
Hi,
I have a CSV file and one of the columns is date in the format of
DD/MM/YYYY. If I open this manually the date column is fine. If however

I
open the same file in code...
Workbooks.Open Filename:="Log.csv"
Excel converts the dates where the first number is less than 13 to an
american type date. I.e. 03/10/2004 becomes 10/03/2004.

How can I stop this from happening???
Ta
Paul



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
ON OPEN VBA Code input incorrectly now excel sheet wont open mmartin New Users to Excel 1 February 16th 11 11:33 PM
the date value of series is incorrectly displayed Johannes Charts and Charting in Excel 0 November 10th 09 05:46 PM
Date format diplays incorrectly esiglin Excel Worksheet Functions 2 September 13th 08 04:00 AM
Column sorting incorrectly Melissa Excel Discussion (Misc queries) 18 October 13th 05 08:45 AM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM


All times are GMT +1. The time now is 12:41 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"