Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Perry
 
Posts: n/a
Default Open an Excel file with a date as today in a macro

Hello,

I'm creating a daily report with certain data.

One of the steps to create this report is the input of certain data
from one Excel file into another. The destination file for this data is
an Excel file which always has a name as follows:

--- Daily_Report_Perry_dd-mm-yyyy.xls

How do I create a macro which always opens the file above with the
"today" date? By example today, wednesday the 9th of November, the
following file should be opened:

--- Daily_Report_Perry_09-11-2005.xls

  #2   Report Post  
Bernie Deitrick
 
Posts: n/a
Default Open an Excel file with a date as today in a macro

Perry,

When you use the file name, create it using the Format function:

Dim myFileName As String
myFileName = "Daily_Report_Perry_" & Format(Now, "dd-mm-yyyy") & ".xls"
MsgBox myFileName

Then use the variable myFileName wherever you were using the name string.

HTH,
Bernie
MS Excel MVP


"Perry" wrote in message
oups.com...
Hello,

I'm creating a daily report with certain data.

One of the steps to create this report is the input of certain data
from one Excel file into another. The destination file for this data is
an Excel file which always has a name as follows:

--- Daily_Report_Perry_dd-mm-yyyy.xls

How do I create a macro which always opens the file above with the
"today" date? By example today, wednesday the 9th of November, the
following file should be opened:

--- Daily_Report_Perry_09-11-2005.xls



  #3   Report Post  
Bernie Deitrick
 
Posts: n/a
Default Open an Excel file with a date as today in a macro

Perry,

I guess I should have included how to open the file:

Dim myFileName As String
myFileName = "Daily_Report_Perry_" & Format(Now, "dd-mm-yyyy") & ".xls"
Workbooks.Open "C:\Foldername\" & myFileName

HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Perry,

When you use the file name, create it using the Format function:

Dim myFileName As String
myFileName = "Daily_Report_Perry_" & Format(Now, "dd-mm-yyyy") & ".xls"
MsgBox myFileName

Then use the variable myFileName wherever you were using the name string.

HTH,
Bernie
MS Excel MVP


"Perry" wrote in message
oups.com...
Hello,

I'm creating a daily report with certain data.

One of the steps to create this report is the input of certain data
from one Excel file into another. The destination file for this data is
an Excel file which always has a name as follows:

--- Daily_Report_Perry_dd-mm-yyyy.xls

How do I create a macro which always opens the file above with the
"today" date? By example today, wednesday the 9th of November, the
following file should be opened:

--- Daily_Report_Perry_09-11-2005.xls





  #4   Report Post  
bpeltzer
 
Posts: n/a
Default Open an Excel file with a date as today in a macro

Your open statement would be something like
Workbooks.Open Filename:="c:\temp\" & Format(Date, "mm-dd-yyyy") & ".xls"


"Perry" wrote:

Hello,

I'm creating a daily report with certain data.

One of the steps to create this report is the input of certain data
from one Excel file into another. The destination file for this data is
an Excel file which always has a name as follows:

--- Daily_Report_Perry_dd-mm-yyyy.xls

How do I create a macro which always opens the file above with the
"today" date? By example today, wednesday the 9th of November, the
following file should be opened:

--- Daily_Report_Perry_09-11-2005.xls


  #5   Report Post  
Perry
 
Posts: n/a
Default Open an Excel file with a date as today in a macro

Bernie,

Thank you! It works perfectly.

I'd already tried the "&Format(Now, "dd-mm-yyyy") & ".xls" function but
somehow it didn't work. Now it does!

I think it had to do with Dim myFileName As String.

Perry

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
Saved *.csv file gives SYLK file type warning upon Excel 2003 open Tom Excel Discussion (Misc queries) 5 March 19th 08 03:15 PM
cannot open excel file, please help!!! sunlite Excel Discussion (Misc queries) 0 September 5th 05 05:29 PM
pls Help, Excel File not open Nguyen Excel Discussion (Misc queries) 4 August 23rd 05 12:21 PM
How do I open a Quattro Pro 7.0 file in Excel 2003 cpatrick83 Excel Discussion (Misc queries) 0 August 22nd 05 09:41 PM
Open a file in excel from a link in eplorer Dave Peterson Excel Discussion (Misc queries) 0 November 26th 04 01:25 AM


All times are GMT +1. The time now is 07:05 AM.

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"