code to save backup file 2 alt file

nickolushenry

New Member
Joined
Jan 7, 2011
Messages
31
Is it possible to automatically save an excel backup file when the original is saved or closed out? <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
example<o:p></o:p>
<o:p> </o:p>
- 1 sheet multiple users will enter data onto<o:p></o:p>
- Main Excel File is saved to "A" drive<o:p></o:p>
- Backup Excel File is saved to "B" drive<o:p></o:p>
<o:p> </o:p>
Using some vb/macro/something, would it be possible to set up the file when a user hits the save button or closes the file out, have it (automatically in the background) save a backup to drive "B" and replace the file that is on drive "B" (thus not creating multiple copies)?<o:p></o:p>
<o:p> </o:p>
Thanks to all that help out in advance!!! =)
 
That helped me identify that my code was putting the file name in the path twice; however, I am still getting the access denied issue.....
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Do you open up the file from that network location?

Or is another user consuming the file in the network location?
 
Upvote 0
BTW, this code works perfectly for me:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Me.SaveCopyAs "C:\" & Me.Name
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Me.SaveCopyAs "C:\" & Me.Name
End Sub

Does it work for your file?
 
Upvote 0
Another user will be the consumer in that location. Oh wait...I set the file in that location to a read only file. So it wasn't let me overwrite it. So now it works but I want the file to be a read only file. Thoughts?
 
Upvote 0
Read only by Windows or Excel?

You could delete the file (the Kill statement) and save it again.

Last step, change the settings to read only.
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top