Append DateTime to Fiename, saveCopy

G

Guest

Hi All...........

I'm having trouble with the following code in XL97/SR2.....getting "cant
find file" error and not making the copy.........could anybody tell me what's
wrong please?

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim sName as String
sName = ThisWorkbook.Name
sName = Left(sName,len(sname)-4) & _
Format(now,"yyyymmdd_hh:mm:ss") & ".xls"
Thisworkbook.SavecopyAs sName
End Sub

TIA
Vaya con Dios,
Chuck, CABGx3
 
G

Guest

Can you manually do a saveas with that name on that system?

Would it be better to use Thisworkbook.FullName
 
G

Guest

Hi Tom.......
No, I could not do a manual "save as" with that filename until I changed the
colon's in the time sequence to underscores........but still, it took your
"FullName" suggestion to make the whole thing work fine and save the new file
right back to the directory the original came from...........really, really
nice now......

Thank you very much.......

Vaya con Dios,
Chuck, CABGx3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top