ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Knowing what Folder I'm in when I open from a shortcut (https://www.excelbanter.com/excel-programming/417531-knowing-what-folder-im-when-i-open-shortcut.html)

Mac Lingo

Knowing what Folder I'm in when I open from a shortcut
 
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



OssieMac

Knowing what Folder I'm in when I open from a shortcut
 
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.


--
Regards,

OssieMac


"Mac Lingo" wrote:

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




Mac Lingo

Knowing what Folder I'm in when I open from a shortcut
 
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éctor Miguel

Knowing what Folder I'm in when I open from a shortcut
 
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.



OssieMac

Knowing what Folder I'm in when I open from a shortcut
 
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.

--
Regards,

OssieMac


"Héctor Miguel" wrote:

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.




OssieMac

Knowing what Folder I'm in when I open from a shortcut
 
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

--
Regards,

OssieMac


"Héctor Miguel" wrote:

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.




Mac Lingo

Knowing what Folder I'm in when I open from a shortcut
 
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




All times are GMT +1. The time now is 03:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com