Open Files with Macro or switch windows with macro

N

Noe

How can I open a file with macros if the date change every day, i try to do
the macro to open the files i need but it give me an error every time the
date change.
Its the same if i open the file and try to go back by window its give in me
an error
Windows(" REPORT 09262009.xls").Activate I just want to the macro reconize
every time its change the date. can some one help me with this problem i have
 
J

JP

How about

Dim todaysDate As String
todaysDate = Format(Now, "mmddyyyy")

Windows(" REPORT " & todaysDate & ".xls").Activate

That will always open the spreadsheet for today. "REPORT 09292009.xls"
today, "REPORT 09302009.xls" tomorrow, and so on.

Does that work for you?

--JP
 
N

Noe

Jp this is great, I just have another question can i put with a number how
many dates the formula can go, like if i want the date of yestarday will be
-1
or one day before yestarday -2 something like that.
 
N

Noe

Windows(" REPORT 09262009.xls").Activate The formula you sent me was only
read from todays date and if i need to open that file 09262009 its give in me
an error.
 
N

Noe

JP
I did this but its not working but i belive its correct.
Dim yestardate As String
todaysdate = Format((Now) - 3, "mmddyyyy")

Windows(" REPORT " & todaysdate & " .xls").Activate
 
Top