Save new file in same directory

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?
 
G

Guest

Assuming you are doing a "Save As" on the ActiveWorkbook...
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "Backup.xls"
 
C

Chip Pearson

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)
 

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