Problem saving backup file with VBA

J

JoAnn

Can someone tell me what is wrong with this code?

It keeps generating Runtime Error 1004 (can't find file) on the SaveAs line
& I can't figure out why. I also tried using CopyAs & got the same error.

I've got this in Module1 not ThisWorkbook.

Sub SAVE_Quit()
' save current sheet in same location, create backup & quit Excel

Path = "http://dms/sites/cfg/1/f/f/CAS Product Documentation/_ DRAFT (Submit
Docs for Formatting - Report and Docs)/Bkp/"

Name = Application.UserName & Format(Date, "mmddyy") & "_" & Format(Time,
"hh:mm:ss") & ".xls"

Bkp = Path & Name

ActiveWorkbook.Save
ActiveWorkbook.SaveAs Filename:=Bkp
Application.Quit

End Sub

Also ... the 1st save prompts to save as same filename to the same location.
Anyway to make that only happen if someone else is in the same file?

Since this is in Sharepoint, we see "Read Only" on all our opened files & I
need a way to know if someone else is truly in the file before saving it (to
ensure they don't overwrite).

Thanks,
 
J

JP

You should avoid using variables that look like keywords. "Path" is
one of those ambiguous words that I avoid. Try "strPath" to indicate
that the variable holds a String.

HTH,
JP
 

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

Top