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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting directory in a macro 1

Status
Not open for further replies.

tagrove

Programmer
Dec 17, 2004
6
0
0
US
I have an application that I want to have Excel open files in a specific directory. I don't want to hard-code the directory in the module.

I tried a few things, but Excel always looks in the default directory used when it starts. ie: "c:\documents and settings\user\my documents\"

How can I have my macro set the directory that I want?
 
tagrove,

If it is an option you could use the following at startup.

/p <folder> Forces Excel to use the path that you specify as the active
path instead of the default path.


I hope this helps..

Good Luck...

 
Thank HitchUser, I appreciate the input.

But, I was looking for something that could be done once inside Excel.

I've tried:

application.defaultfilepath

but it still tries to open in the file path of when Excel opened.
 
A bit more History:

Th reason for this is that I have a USB Jumpdrive. I have spreadsheets and other files that are stored on the drive that I need to be able to access while using different computers.

Sometimes the Jumpdrive is the E: drive, others it is G:, etc. You get the picture. I would like to be able to dynamically point the default file location when I open the spreadsheet, so it knows where to find the data files specified in the macros.

Sorry, I should have posted the explanation in the first post.
 
Thanks, the Excelforum one looks like it will work for me, when combined with grabbing the default drive from the file opened. Also, if I put it in the workbook open event, that should take care of everything.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top