View Full Version : Determining the Path to a File in Win 7

01-21-2010, 01:13 PM
:igiveup: This topic might not be appropriate for this forum, so I will apologize ahead of time.
I'm a newbie to Windows 7 and its file system. While examining the Windows Explorer displays and reading the help, I determined that a file created in Win 7 has one place it is stored . . . the so-called default storage location. After that the file name can be copied to any of a number of Libraries and/or folders. The consequence of this is that Window Explorer will display all the "locations" that a particular file name may reside. That means that the same name can appear in different paths. I suppose that a given folder name can also appear in different paths.

My problem is that if I am writing a macro for Excel that needs a reference to the path for the Excel file named "Personal.xlsm", I can't just do a quick visual scan of Windows Explorer to find where Personal.xlsm shows up because there may be several different paths to that file name. So you will say "Choose the path that contains the default folder". But how do I determine what the default folder is if I didn't create the file and do the first save?

01-21-2010, 10:55 PM
Cheap way: Record a macro and select "Personal Workbook". Save.
If you still need the path open the vbe. Select the personal workbook project, drop to the immediate window and type:? ThisWorkBook.FullPath

01-30-2010, 03:39 PM
Use the Watch window to look at the Application, or look at the Trusted Locations under Options, Trust Center

Option Explicit
Sub drv()
MsgBox Application.AltStartupPath
MsgBox Application.DefaultFilePath

MsgBox Application.LibraryPath

'where excel.exe is
MsgBox Application.Path

'where personal.xlsm probably is
MsgBox Application.StartupPath

MsgBox Application.TemplatesPath

MsgBox Application.UserLibraryPath
End Sub