Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

opening an exported timestamped file

Status
Not open for further replies.

r10701

Programmer
Dec 20, 2004
14
US
I have a macro that exports a forms results to excel. I'm using the Output to function in the macro This is what the code looks like. ="g:\ms\rscplan\x65\" & Format(Now(),"mmddyyhhnn") & ".xls"

This is working correctly. But when I try to RunApp to open the file it does not work. I get an error message that says the file can't be found. This is what the code looks like.

excel.exe ="g:\ms\rscplan\x65\" & Format(Now(),'mmddyyhhnn') & ".xls"

I'm thinking it has something to do with how it is timestamped and it can't find that exact time because it changed? Any thoughts?

Thanks
 
Store the workbook pathname before the OutputTo call and use the stored value whenever you need it.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for your help. So shpuld I save it as the timestamp and then output it? I'm not exactly sure what you mean.

Thanks
 
Something like this:
myWB = "g:\ms\rscplan\x65\" & Format(Now(),"mmddyyhhnn") & ".xls"
Then use myWB in the OutputTo call AND when you want to open it.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Will this work in Access 97? I don't see how to do the myWB part.

Thanks
 
This is VBA code.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top