Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filename saving

Status
Not open for further replies.

DannyTmoov2

IS-IT--Management
Jan 7, 2003
49
GB
Simple relative saving problem: I have a macro that opens a new workbook and saves it with a filename, how do I save it to the same location as the original file (i.e. without c:\folder1\folder2\filename.xls)
Currently using
ActiveWorkbook.SaveAs FileName:="c:\folder\filename.xls"

but would like to just save as "filename.xls" in same folder as the workbook that launched the macro. currently just saves it in c:\filename.xls

Cheers
 
Use

old_path = activeworkbook.path
' to get the path which has the macro run.

And use this to save your workbook.

ActiveWorkbook.SaveAs FileName:=old_path + "\filename.xls"


Hope this helps.

Ram P
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top