Consulting

Results 1 to 3 of 3

Thread: Determining the Path to a File in Win 7

  1. #1

    Determining the Path to a File in Win 7

    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?
    Sid

  2. #2
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    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:[vba]? ThisWorkBook.FullPath[/vba]
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,711
    Location
    Use the Watch window to look at the Application, or look at the Trusted Locations under Options, Trust Center

    [VBA]
    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

    'templates
    MsgBox Application.TemplatesPath

    'addins
    MsgBox Application.UserLibraryPath
    End Sub[/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •