Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problem saving backup file with VBA
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, -- JoAnn |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problem saving backup file with VBA
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 On Apr 2, 2:46*pm, JoAnn wrote: 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/CASProduct 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excels auto recovery file is saving as a backup, how do i stop tha | Setting up and Configuration of Excel | |||
Changing default fie for backup saving | Excel Discussion (Misc queries) | |||
saving backup | Excel Programming | |||
Saving backup file on file open | Excel Programming | |||
Backup in Saving a file in Excel 2002 | Excel Discussion (Misc queries) |