Save a backup file

  • Thread starter Carrie_Loos via OfficeKB.com
  • Start date
C

Carrie_Loos via OfficeKB.com

I have a file that I update each day and then it is updated by others. (Not a
shared file) Everyday I open and run my code to pull in yesterdays updates.
Before I pull in the updates I want to save a copy, "backup" in the same path
on the server where the original file is located. I have tried various
attempts which seem so simple but they are saving elsewhere...Can anyone
direct me on how to write the piece to make sure the file saves where I want
it to?

Thanks
 
J

JLGWhiz

While the workbook you want backup is open and is the active workbook, you
can set a variable to its path.

myPath = ActiveWorkbook.Path

Then use that variable in the SaveAs command as part of the file name.

ActiveWorkbook.SaveAs Filename:=myPath & "\<backupname>.xls?"

backupname would be the actual name you give to the backup file and the file
extension would be based on the format to which you want to save the file.
It is better to use the actual workbook name instead of ActiveWorkbook in
case that workbook is not active at the time you decide to initiate the path
variable or do the saveas.
 
R

Ron de Bruin

Look also at SaveCopyAs
This way the original file stay open and your copy is saved where you want

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm



JLGWhiz said:
While the workbook you want backup is open and is the active workbook, you
can set a variable to its path.

myPath = ActiveWorkbook.Path

Then use that variable in the SaveAs command as part of the file name.

ActiveWorkbook.SaveAs Filename:=myPath & "\<backupname>.xls?"

backupname would be the actual name you give to the backup file and the file
extension would be based on the format to which you want to save the file.
It is better to use the actual workbook name instead of ActiveWorkbook in
case that workbook is not active at the time you decide to initiate the path
variable or do the saveas.
 
C

Carrie_Loos via OfficeKB.com

Thank you - this is exactly what I needed
While the workbook you want backup is open and is the active workbook, you
can set a variable to its path.

myPath = ActiveWorkbook.Path

Then use that variable in the SaveAs command as part of the file name.

ActiveWorkbook.SaveAs Filename:=myPath & "\<backupname>.xls?"

backupname would be the actual name you give to the backup file and the file
extension would be based on the format to which you want to save the file.
It is better to use the actual workbook name instead of ActiveWorkbook in
case that workbook is not active at the time you decide to initiate the path
variable or do the saveas.
I have a file that I update each day and then it is updated by others. (Not
a
[quoted text clipped - 9 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top