Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excels auto recovery file is saving as a backup, how do i stop tha EPSCoR Setting up and Configuration of Excel 6 March 20th 09 05:49 PM
Changing default fie for backup saving GrammyBarb Excel Discussion (Misc queries) 2 September 29th 08 10:10 PM
saving backup AmyTaylor[_35_] Excel Programming 7 January 12th 06 12:07 PM
Saving backup file on file open AmyTaylor[_32_] Excel Programming 4 January 10th 06 02:48 PM
Backup in Saving a file in Excel 2002 4rs Excel Discussion (Misc queries) 1 January 14th 05 05:09 AM


All times are GMT +1. The time now is 04:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"