PC Review


Reply
Thread Tools Rate Thread

Date format on opening a csv file in Excel 2007

 
 
=?Utf-8?B?R2xlYW0=?=
Guest
Posts: n/a
 
      4th Nov 2007
If I open the file manually from Excel, the dates appear in the correct
format (dd/mm/yy)
If I open the file from a macro, the dates appear in the wrong format
(mm/dd/yy)
I have tried copying the csv file to a txt file and the same happens - open
manualy and the dates are fine. Open from a macro and it is as though I have
flown across the Atlantic in 2 seconds!

Here is an extract of my code
DirPath = "C:\Program Files\Book-IT\CRM\"
fName = "TRM_Bookings.CSV"
fNameT = "TRM_Bookings.txt"
' need to rename file as a txt file
FileCopy DirPath & fName, DirPath & fNameT

Workbooks.OpenText Filename:="C:\Program
Files\Book-IT\CRM\TRM_Bookings.txt" _
, Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited,
TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False,
Semicolon:=False _
, Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1,
1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1),
Array(7, 1), Array(8, 1), _
Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1),
Array(14, 1), _
Array(15, 1), Array(16, 1), Array(17, 1)), TrailingMinusNumbers:=True
Columns("H:H").EntireColumn.AutoFit

 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2xlYW0=?=
Guest
Posts: n/a
 
      4th Nov 2007
I have made some progress! If I change the code to array(4,4) instead of
(4,1) the date format is correct in column 4. The dates in this column are
just dates e.g. 05/11/2007.
However columns 8 and 9 are dates plus times e.g 05/11/2007 11:00.
Changing the code from array(8,1) to array(8,4) does not work.
Any ideas?

"Gleam" wrote:

> If I open the file manually from Excel, the dates appear in the correct
> format (dd/mm/yy)
> If I open the file from a macro, the dates appear in the wrong format
> (mm/dd/yy)
> I have tried copying the csv file to a txt file and the same happens - open
> manualy and the dates are fine. Open from a macro and it is as though I have
> flown across the Atlantic in 2 seconds!
>
> Here is an extract of my code
> DirPath = "C:\Program Files\Book-IT\CRM\"
> fName = "TRM_Bookings.CSV"
> fNameT = "TRM_Bookings.txt"
> ' need to rename file as a txt file
> FileCopy DirPath & fName, DirPath & fNameT
>
> Workbooks.OpenText Filename:="C:\Program
> Files\Book-IT\CRM\TRM_Bookings.txt" _
> , Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited,
> TextQualifier:= _
> xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False,
> Semicolon:=False _
> , Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1,
> 1), _
> Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1),
> Array(7, 1), Array(8, 1), _
> Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1),
> Array(14, 1), _
> Array(15, 1), Array(16, 1), Array(17, 1)), TrailingMinusNumbers:=True
> Columns("H:H").EntireColumn.AutoFit
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
date format problem from opening dbf file in excel 2007 pol Microsoft Excel Misc 5 1st Dec 2008 11:42 AM
File always opens with Date format set - Excel 2007 ale Microsoft Excel Misc 0 30th Dec 2007 02:55 PM
Excel 2007 File Problems (Opening New Format) =?Utf-8?B?R3JhemVu?= Microsoft Excel Misc 2 21st Jul 2006 04:24 PM
opening excel file -> date format problem: DD/MM/YYYY vs MM/DD/YYYY yung Microsoft Excel Programming 2 18th Mar 2005 12:50 PM
Opening a csv file with US date format on a Australian PC =?Utf-8?B?VHJveSBMZWE=?= Microsoft Excel Misc 2 16th Mar 2005 10:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:16 PM.