Knowing what Folder I'm in when I open from a shortcut

M

Mac Lingo

When I open an excel program from a shortcut, the Worksheet.Parent.Path
tells me the folder the workbook was opened from. How do I find out the
folder that the shortcut was in? It is this folder which shows when I do
"Open", so I'm assuming that it's kept somewhere. But I can't figure out
where.

Thanks,
Mac in Berkeley, CA
 
O

OssieMac

Hi Mac,

Am I interpreting your question correctly in assuming that you are referring
to a shortcut icon on your desktop? If so, the Desktop is actually a folder
which normally resides at C:\Documents and Settings\user name\Desktop
Where user name is whatever name has been used for each user.

Also if it is an icon on the desktop then right click on the icon and select
properties. Then select the General tab and you will see the path next to
Location: You might have to click on the actual location then use the arrow
keys to scroll across to read the full path.
 
M

Mac Lingo

OssieMac,

I start from a folder. I open an excel file from a shorcut (to another
folder), but I am still in the original folder I started in.


My question is how the in Excel VBA programming environment can I know what
folder I started the Excel program from (not the folder the excel program is
in).

Thanks,
Mac
 
H

Héctor Miguel

hi, !
I start from a folder.
I open an excel file from a shorcut (to another folder)
but I am still in the original folder I started in.

at that moment, you know exactly which folder you are and/or
where is located the short-cut link-file to open your document/excel
My question is how the in Excel VBA programming environment can I know
what folder I started the Excel program from (not the folder the excel program is in).

suppose excel is closed, and suddenly it opens by means of... whatever, so...
how would excel be sure and tell you where you were while excel opens ?
- an hyperlink from another application (word, ppt, ...) ???
- a shorcut from your desktop ???
- a shortcut from windows-explorer or MyPC, or... ???

AFAIK, when excel opens from a shortcut, it's current directory is still the Application.DefaultFilePath

hth,
hector.
 
O

OssieMac

Still not sure that I fully understand what it is you want. The following
code out of help (slightly modified with the filespec) provides info about
the current workbook.
 
O

OssieMac

I lost my last reply part way through so not sure if it posted but here it is
again because it was not all there.

I am still not sure exactly what it is you want but the following code out
of help (modified with the filespec) will give you the path of the workbook.

Sub ShowFileAccessInfo()
Dim filespec
Dim fs, d, f, s

filespec = ThisWorkbook.Name

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
s = UCase(f.Path) & vbCrLf
s = s & "Created: " & f.DateCreated & vbCrLf
s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf
s = s & "Last Modified: " & f.DateLastModified
MsgBox s, 0, "File Access Info"
End Sub
 
M

Mac Lingo

Thank you for trying. But...

When I open Excel from a shortcut, oncel Excel is running I know where its
file is from (Parent.Path). What I don't know once I'm inside the running
Excel program is the path to the folder I clicked on to start the program
(ie: the folder the shortcut was in). Is this information displayable
anywhere from inside the program?

Mac in Berkeley, CA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top