Save file works, but not it the right folder

kevin071572

New Member
Joined
Jul 19, 2007
Messages
7
I'm winging my way trying to learn VBA but I can't find the answer to this problem. I have a macro that renames the current file and saves a copy with a new file name based of the value of 3 different cells. But it doesn't save it in the same folder that it opened from. I can't just copy the code to here since it's on a private network that doesn't access the internet. It uses the line & CurDir & "\" MyCell & ".xls"

That line doesn't save it in the folder the file started from. Am I missing something to complete the path to the file? Am I even asking the right question?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Don't use CurDir, that returns the current directory not the workbooks path.

You could probably use it sometimes as the current directory could be the same as the workbook's path but that would be a bit (lot) hit and miss.

Use ThisWorkbook.Path.:)
 
Upvote 0
change

Code:
& CurDir & "\" MyCell & ".xls"

to
Code:
& "C:\ActualCompletePath\" & MyCell & ".xls"
 
Upvote 0
change

Code:
& CurDir & "\" MyCell & ".xls"

to
Code:
& "C:\ActualCompletePath\" & MyCell & ".xls"

Thanks, but the folder will change every month and I'm setting this up for our replacements in a couple months.

I'll try the ThisWorkbook.Path in a couple minutes
Thanks for your help
 
Upvote 0

Forum statistics

Threads
1,222,383
Messages
6,165,665
Members
451,983
Latest member
Raph24

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