Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Opening a excel file from a macro

When using the below code I open a file with a column of dates in a
"d/mm/yyyy" format eg 1/07/2008.

When I open the file manually the dates are fine however for some unknown
reason when the file opens with the macro dates with a "d" less then 10 are
converted to a date and changes the order of the day and month eg 7/01/2008.

"d" greater than 9 are not regognised as a date and are shown as a text entry.

Does anyone know what is going on??

Workbooks.Open FILENAME:= Range("DEFAULT_FOLDER") & Range

("WORKING_DEFAULT_FILENAME")
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Opening a excel file from a macro

make sure that your computer's date settigns are not American

"Graeme" wrote:

When using the below code I open a file with a column of dates in a
"d/mm/yyyy" format eg 1/07/2008.

When I open the file manually the dates are fine however for some unknown
reason when the file opens with the macro dates with a "d" less then 10 are
converted to a date and changes the order of the day and month eg 7/01/2008.

"d" greater than 9 are not regognised as a date and are shown as a text entry.

Does anyone know what is going on??

Workbooks.Open FILENAME:= Range("DEFAULT_FOLDER") & Range

("WORKING_DEFAULT_FILENAME")

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Opening a excel file from a macro

If the file you're opening is a CSV file, then rename the file to .txt.

Then instead of using workbooks.open, you can use Workbooks.OpenText. And that
gives you the ability to specify each field (date and the correct order).

ps. When some of your data isn't really converted to a real date, that means
that much of your data that was converted to dates didn't get converted
correctly.

Look at what the source data shows and how the data was brought in. It may be a
date. But it's not the date you want.

Graeme wrote:

When using the below code I open a file with a column of dates in a
"d/mm/yyyy" format eg 1/07/2008.

When I open the file manually the dates are fine however for some unknown
reason when the file opens with the macro dates with a "d" less then 10 are
converted to a date and changes the order of the day and month eg 7/01/2008.

"d" greater than 9 are not regognised as a date and are shown as a text entry.

Does anyone know what is going on??

Workbooks.Open FILENAME:= Range("DEFAULT_FOLDER") & Range

("WORKING_DEFAULT_FILENAME")


--

Dave Peterson
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
Macro for Opening Reuters, Opening Excel File, Closing Excel File Tsp245 Excel Programming 2 August 14th 08 07:24 PM
Opening an Excel file with macro Johan_vl2431 Excel Discussion (Misc queries) 0 May 1st 07 02:57 PM
Automatically run a macro when opening an Excel file Raphael Saddy Excel Programming 10 January 15th 04 04:07 PM
Opening text file in Excel through macro Tom Ogilvy Excel Programming 0 October 7th 03 03:53 PM
Opening text file in Excel through macro shockley Excel Programming 0 October 7th 03 03:49 PM


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