Refer current location

anupam

Board Regular
Joined
May 12, 2004
Messages
70
how to refer current location in vb code.

For eg.
In vb code I want to save my Active Worksheet say "X" with a different name say "Z" in current location(where X is saved). I don't want to give the entire path as the file can be in various location and executing the macro from those location should save the file with different name in that location only.
if I refer my existing file "X" to save as "\Z" it saves in root directory or i.e. in C: Drive and if I refer to save as ".\Z" it saves in my profiles "My Document" folder.
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
7,994
I'm not exactly sure what you're trying to do, but application.path will return the current path in VBA. Perhaps that's enough to get you started?
 

Watch MrExcel Video

Forum statistics

Threads
1,123,085
Messages
5,599,650
Members
414,325
Latest member
kfg1287

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