Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Sep 2004
    Location
    Sydney, New South Wales, Australia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Search for a folder (Word 2000)

    I would like to have a macro that searches for a specified folder then displays the drive and path to the folder. Can anyone provide such a macro?

    Thanks

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search for a folder (Word 2000)

    Do you want the user to be able to search for the folder? If so, then the attached code can be renamed to "FolderBrowser.bas" and imported into your VBA project. It can be called from a macro like:
    <code>
    Sub Browse()
    ShowFolderBrowse ("Testing123")
    End Sub
    </code>
    Alan
    Attached Files Attached Files

  3. #3
    Star Lounger
    Join Date
    Sep 2004
    Location
    Sydney, New South Wales, Australia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search for a folder (Word 2000)

    Thanks Alan

    Thats a very useful bit of code and I can use it to replace some code elsewhere.

    What I would like to do is have a macro in a word document that can determine if a specific folder exists on a network and if it does exist then save the drive and path to the folder. I need to be able to do this without the user navigating to the folder. Is it possible?

    Regards

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Search for a folder (Word 2000)

    Doe you mean that you want to specify a folder name, say "MyFolder" and that you want the code to search the entire network for a folder of that name, nested arbitrarily deep in any server, any share? I don't know how to do that, but depending on the size of the network and the permissions of the user, it could take a LONG time.

  5. #5
    Star Lounger
    Join Date
    Sep 2004
    Location
    Sydney, New South Wales, Australia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search for a folder (Word 2000)

    Hi Hans

    Yes that what I want to do, but it would be an a small network of about 5 computers. If the coding is too complex or the search would take too much time, then I won't pursue that idea.

    In relation to Alan's previous post above, Im not sure that I have structured my macros properly. I have imported his code into a module titled FolderBrowser and I can run the code from a macro in the ThisDocument section
    Sub Browse()
    ShowFolderBrowse ("Testing123")
    End Sub

    and Alan's code works fine, my problem is how do I get the string (FName in the FolderBrowser) back into my macro so that I can use it, am I not dimensioning the variable correctly?

    Thanks

  6. #6
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search for a folder (Word 2000)

    Sorry, I used a function call that just opens the dialog. If you want to save the FName return value, then something like:
    <code>
    Sub Browse()
    Dim retVal as String
    retVal = ShowFolderBrowse ("Testing123")
    End Sub
    </code>
    Alan

  7. #7
    Star Lounger
    Join Date
    Sep 2004
    Location
    Sydney, New South Wales, Australia
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search for a folder (Word 2000)

    Thanks Alan

    I knew it would be easy, should have thought about it a bit longer.

    Regards

Posting Permissions

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