Saving new file in working directory

dl7631

Board Regular
Joined
Mar 6, 2009
Messages
114
Hi!

I created a macro. At the end of this macro I want to save my active workbook as a new file. Here is what I wrote:

ActiveWorkbook.SaveAs Filename:= _
"TV&Radio_" & Sheets("Template").Range("B7") & ".xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False

Problem: It saves the file under "MyDocuments". However, I want it to be saved in the same directory that I am working in.

Advice?

Thanks a lot!
 
Sorry, not sure where exactly I should put a \
Do you mind writing the whole line of the code with "\" included?

In other programs you can do it very easily and in a very straightforward way. For example, in R whenever you do NOT specify the directory it automatically saves things in your working folder.

Thanks!
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I tried:

ActiveWorkbook.SaveAs (sPath & "\TV&Radio_" & Sheets("Template").Range("B7") & ".xlsx")


It worked. Thanks a lot for your help!
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,334
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top