ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I save/update work to appear in 2 seperate files? (https://www.excelbanter.com/excel-discussion-misc-queries/169679-how-do-i-save-update-work-appear-2-seperate-files.html)

Dodeka1

How do I save/update work to appear in 2 seperate files?
 
Each time I save my work I want it to save to two seperate files, without
having to cut and paste the new version across each time. Is this possible?
The shared drive and to my computer.

FSt1

How do I save/update work to appear in 2 seperate files?
 
hi
yes it is. you request is not uncommon. lots of people want to create a
backup as they work. the solution is a duel save. the code i am about to
paste is workbook level code meaning that you will have to paste in a
thisworkbook module. you will also have to replace my file paths with your
file paths. post back if you need further help.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.DisplayAlerts = False
ChDir "E:\Excel\CodeStuff"
ActiveWorkbook.SaveAs Filename:="E:\Excel\CodeStuff\deleteme.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ChDir "C:\Program Files\Microsoft Office\Office10\XLStart"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and settings\deleteme.xls", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:= _
False, CreateBackup:=False
Application.DisplayAlerts = True
End Sub

rergards
FSt1
"Dodeka1" wrote:

Each time I save my work I want it to save to two seperate files, without
having to cut and paste the new version across each time. Is this possible?
The shared drive and to my computer.


Bob Phillips

How do I save/update work to appear in 2 seperate files?
 
Caters for both Save and SaveAs

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim sFile
Application.EnableEvents = False
Cancel = True
If SaveAsUI Then
sFile = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If sFile < False Then
With ThisWorkbook
.SaveAs sFile
.SaveCopyAs .Path & Application.PathSeparator & _
Left(.Name, InStrRev(.Name, ".") - 1) & "_Backup"
End With
End If
Else
With ThisWorkbook
.Save sFile
.SaveCopyAs .Path & Application.PathSeparator & _
Left(.Name, InStrRev(.Name, ".") - 1) & "_Backup"
End With
End If
Application.EnableEvents = True
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Dodeka1" wrote in message
...
Each time I save my work I want it to save to two seperate files, without
having to cut and paste the new version across each time. Is this
possible?
The shared drive and to my computer.





All times are GMT +1. The time now is 05:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com