ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy a workbook (https://www.excelbanter.com/excel-programming/330695-copy-workbook.html)

Robert Gillard

Copy a workbook
 
I need to automate the copy of a workbook.? I have an Excel
spreadsheet located at C:\Reports\Test.xls, I need to copy it to
D:\BackUpReports\

What is the best way to do this.

With thanks

Bob



Daniel CHEN

Copy a workbook
 
Use ActiveWorkbook.SaveCopyAs ... which will save a backup copy for you.

You can put the code in one of the following sub:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
' if you want save a backup copy before close the file
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
' if you want save a backup copy before any saving action
End Sub

Private Sub Workbook_Open()
' if you want save a backup copy before file open
End Sub



"Robert Gillard" wrote in message
k...
I need to automate the copy of a workbook.? I have an Excel
spreadsheet located at C:\Reports\Test.xls, I need to copy it to
D:\BackUpReports\

What is the best way to do this.

With thanks

Bob




Harald Staff

Copy a workbook
 
Hi Bob

From an external macro, something like

Sub test()
FileCopy "C:\temp\song.mp3", "D:\Anthems\song.mp3"
End Sub

from a macro within the file itself, something like

Sub test2()
ThisWorkbook.SaveCopyAs "D:\Anthems\" & ThisWorkbook.Name
End Sub

HTH. Best wishes Harald

"Robert Gillard" skrev i melding
k...
I need to automate the copy of a workbook.? I have an Excel
spreadsheet located at C:\Reports\Test.xls, I need to copy it to
D:\BackUpReports\

What is the best way to do this.

With thanks

Bob






All times are GMT +1. The time now is 03:49 PM.

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