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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
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

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
change

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

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

kevin071572

New Member
Joined
Jul 19, 2007
Messages
7
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,190,811
Messages
5,983,050
Members
439,817
Latest member
jessicabrown

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
Top