+ Reply to Thread
Results 1 to 4 of 4

Folder Path.

Hybrid View

  1. #1
    Registered User
    Join Date
    01-19-2007
    Location
    Bangalore, India
    Posts
    66

    Folder Path.

    Hi,

    I have some VBA code. Somewhere in my application I want the user to be able to browse through the folders and files. My problem is how can I fetch the path of a folder while a user selects it? I do not want user to go to the file location. I just want the folder location.

    Regards,
    Gajendra Gupta

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Hi Gupta, although this code looks like it will open the file it actually just gets you the file path and location:

    Sub findfiles()
    Dim CurrentDir As Variant
    CurrentDir = CurDir()
    
    Dim fNameAndPath As Variant
    If fNameAndPath <> False Then Reset
    fNameAndPath = ""
    fNameAndPath = Application.GetOpenFilename(Filefilter:="Excel Files(*.xls), *.xls", Title:="Highlight File To Be Opened")
    
    If fNameAndPath = False Then
    
    MsgBox (" No File Selected! ")
    
    Else
    
    MsgBox "Selected file is:" & fNameAndPath
    
    End If
    Reset:
    End Sub
    Regards,
    Simon

  3. #3
    Registered User
    Join Date
    01-19-2007
    Location
    Bangalore, India
    Posts
    66
    Simon thank for your reply. Yes this is the way you open a file but I do not want user to get in to the folder I just want him to select the folder and by selecting the folder only I should be able to get the folder path. Any idea?

    Regards,
    Gajendra Gupta

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Gajendra.Gupta,

    Visit Chip Pearson's site. Here is a link that will take you to code examples of browsing for folders.

    http://www.cpearson.com/excel/BrowseFolder.htm

    Sincerely,
    Leith Ross

+ 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