Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default opening excel file - date format problem: DD/MM/YYYY vs MM/DD/YYYY

Hi,

I am using Excel 2000, programming with VB6.

I have a HTML file "Temp.xls" (yes, in xls extension) with a table only.
There is a cell containing a date:
..... <tr<td07/12/2004</td</tr...
Note that this date means Dec 7, 2004 (in DD/MM/YYYY format).
When I open this file in Excel, it shows the date format well as above.
But when I write code to open it:

Dim xlsApp as Object
Dim FilePath as String
.....
FilePath = "C:\Temp.xls"
Set xlsApp = Nothing
Set xlsApp = CreateObject("Excel.Application")
xlsApp.Workbooks.Open (FilePath)
....

I find that the date becomes 12/07/2004, which is not what I want.

The date fornat in my regional setting is dd/mm/yyyy already. How can I
solve this problem?

Thanks a lot!

Yung


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default opening excel file - date format problem: DD/MM/YYYY vs MM/DD/YYYY

I think you have to format that cell in your code.

Sheets("mysheet").Range("myrange").Value = Format(Now(), "dd-mm-yy")

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default opening excel file - date format problem: DD/MM/YYYY vs MM/DD/YYYY

I see you are using xl2000. I think in that case, you would need to find
the date and convert it - formatting the cell after the fact as suggested
will have no effect.

If it displays as

12/07/2004, then you can use vba's conformance to US English to your
advantage (untested, but try)

ActiveCell.Value = ActiveCell.Text

in your code after you open the file (ActiveCell represents a reference to
the cell with the date)
--
Regards,
Tom Ogilvy

"yung" wrote in message
...
Hi,

I am using Excel 2000, programming with VB6.

I have a HTML file "Temp.xls" (yes, in xls extension) with a table only.
There is a cell containing a date:
.... <tr<td07/12/2004</td</tr...
Note that this date means Dec 7, 2004 (in DD/MM/YYYY format).
When I open this file in Excel, it shows the date format well as above.
But when I write code to open it:

Dim xlsApp as Object
Dim FilePath as String
....
FilePath = "C:\Temp.xls"
Set xlsApp = Nothing
Set xlsApp = CreateObject("Excel.Application")
xlsApp.Workbooks.Open (FilePath)
...

I find that the date becomes 12/07/2004, which is not what I want.

The date fornat in my regional setting is dd/mm/yyyy already. How can I
solve this problem?

Thanks a lot!

Yung




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
Format date dd.mm.yyyy to dd/mm/yyyy Kiwi User Excel Discussion (Misc queries) 7 May 7th 23 11:44 AM
change date format from dd/mm/yyyy to mm/yyyy flow23 Excel Discussion (Misc queries) 3 April 4th 23 11:26 AM
Help with date format mm/dd/yyyy vs. dd/mm/yyyy Dream Excel Discussion (Misc queries) 3 September 10th 09 07:33 PM
how do I change date from mm/dd/yyyy to dd:mm:yyyy format in Excel Jack Wilson New Users to Excel 4 July 18th 06 01:57 PM
Having problem getting date into format: yyyy/mm/dd Andrew[_13_] Excel Programming 1 July 15th 03 09:49 PM


All times are GMT +1. The time now is 09:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"