I start an Excel program from a shortcut in different folders. I know that I can find the path of the Excel program in "Parent.Path". But I don't know how to find the path of the folder the shortcut was in. It should be findable because when I try to do something like <Save>, Excel knows the correct folder there.
An example: I open Excel in "Folder 1" using a shortcut to the Excel Program in "Folder 2". Parent.Path tells me "Folder 2". How do I find out what "Folder 1" is from inside Excel?
Thanks,
Mac in Berkeley, CA
Hello CaptMac,
Welocme to the Forum!
If I understand you correctly, you referring to a workbook and not the Excel application. The following code will return the full directory path for the workbook.
Sincerely,Code:ThisWorkbook.Path
Leith Ross
Thanks, Leith, for the response.
With regards to my original example
ThisWorkbook.Path yields the path to the folder the workbook is in: ie. /../Folder2.
What I'm looking for is something that yields the path to the folder the shortcut was in: ie. /../Folder 1.
Mac
Does this work
Code:MsgBox CurDir()
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
Thanks, RoyUK, for the reply. But...
CurDir() gives me a pointer to my home directory, not to /../ Folder1
when I tried it in my code.
Mac
It turns out that what I thought might work does NOT.
The only reference to external files is the WorkBook.Parent. SO that's all one can find out.
Captn Mac
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks