Save new file in same directory

  • Thread starter Thread starter Gert-Jan
  • Start date Start date
G

Gert-Jan

In a workbook I create a backup.xls file. I want that file standard to be
saved in the same directory where the main file is located. How can do that
in a macro?
 
Assuming you are doing a "Save As" on the ActiveWorkbook...
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "Backup.xls"
 
You need a path separator character in there.

ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & _
Application.PathSeparator & "Backup.xls"

For backups, it is better to use SaveCopyAs rather than SaveAs.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)
 
Back
Top