+ Reply to Thread
Results 1 to 5 of 5

Extracting File Path from Application.GetOpenFile

Hybrid View

  1. #1
    Registered User
    Join Date
    08-25-2010
    Location
    Northants, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Extracting File Path from Application.GetOpenFile

    Hi all,

    I'm currently using the following code:-
    PathName = Application.GetOpenFilename("AutoCad (*.Dwg), *.dwg", , "Drawing Files", , True) 'get Drawing Files
    The variable PathName is a Variant as it can also be an array from selecting multiple file.

    What I am trying to do is extract the path to the file and store as a string

    I do not wish to invoke the GetOpenFilename again - Is there a simple way to do this?

    Thanks in advance

    Steve
    Last edited by Retec123; 08-25-2010 at 07:51 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Extracting File Path from Application.GetOpenFile

        Dim sPath As String
        Dim sFile As String
        
        sFile = "C:\myPath\myFile.xls"
        sPath = Left(sFile, InStrRev(sFile, "\"))
        MsgBox sPath
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-25-2010
    Location
    Northants, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Extracting File Path from Application.GetOpenFile

    Hi shg,

    Sorry.. I probably didn't make it quite clear..
    The path where I direct Application.GetOpenFile is not where my .xls resides..
    I am trying to read the path name as a string from the App.GetOpenFile variable 'PathName' because I wish to automatically select files at that destination to read their filename without having to use the App.GetOpenFile again..

  4. #4
    Registered User
    Join Date
    08-25-2010
    Location
    Northants, England
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Extracting File Path from Application.GetOpenFile

    Self answered as follows.......


    GOFPathName = Application.GetOpenFilename("AutoCad (*.dwg), *.dwg", , "Drawing File", , True) 
    JustThePathName = Left(GOFPathName(1), InStrRev(GOFPathName(1), "\") ) 
    Many Thanks
    Last edited by Retec123; 08-25-2010 at 07:53 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Extracting File Path from Application.GetOpenFile

    Glad you got it sorted.

    Would you please take a few minutes to read the forum rules, and then edit your post to add CODE tags?

    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1