View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
davethewelder davethewelder is offline
external usenet poster
 
Posts: 62
Default open a file automatically which was created yesterday

Joel, many thanks it works a treat. Amazing how one little missing bit can
stump you for ages.

Cheers

Davie

"Joel" wrote:


Workbooks.Open Filename:="Z:\" & NewName & ".csv"

"davethewelder" wrote:

Joel, I am not including weekends but I don't think it makes a difference if
it takes todays' date and subtracts one.

I tried the code below but it did not find the file "NewName".

ub tryopen()
basename = "Report15Probability"
yesterday = Format(Date - 1, "yyyymmdd")
NewName = basename & yesterday

'
ChDir "Z:\"
Workbooks.Open Filename:="Z:\NewName.csv"
End Sub

Have I entered this correctly?
Sometimes on this computer when you hit New or reply it does not open the
popup window to reply.

"Joel" wrote:

Below will work, but are you including weekends and holidays?-

basename = "Report15Probability"
yesterday = Format(Date - 1, "yyyymmdd")
NewName = basename & yesterday


"davethewelder" wrote:

Hi, i have a macro which opens a file which is created automatically with a
date in the filename. I can add the date to the filename but I want to open
the file in a series of macros to be run every morning. I have tried using
some examples from the disscussion board but no success yet.

I want the filename updated with yesterday's date.

The constant name of the file is Report15Probability whith the date
yyyymmdd. I am about to try the LastMofifiedYesterday property but I am
running out of options.

Sorry for not posting the code but this is due to restrictions on e-mail

Hope some one can help.

Davie