Consulting

Results 1 to 8 of 8

Thread: Get result from a search in explorer into a Access listbox ?

  1. #1
    VBAX Regular
    Joined
    Jan 2018
    Posts
    52
    Location

    Get result from a search in explorer into a Access listbox ?

    I have made a test form with at textbox for my search criteria AND a button to execute the search - simple and easy, and it shows me a explorer window with the search results.

    Try yourself with this simple code behind the button:

        Dim WhatToSearchFor As String
        Dim WhereToSearch As String
        WhatToSearchFor = Chr(34) & txtSearchFor.Value & Chr(34)
        WhereToSearch = Environ("SlægtHovedmappe")
        Shell "explorer.exe " & Chr(34) & "search-ms:query=" & WhatToSearchFor & "&crumb=location:" & WhereToSearch & Chr(34), vbNormalFocus
    It you want to search for FRASES (in my danish version) you HAVE to use double qoutation marks around the frase, like this: "I look for this frase in my documents"

    The search is very, VERY fast and it looks into doc, docx, PDF, msg ... you name it, in all subfolders - I think it's a very powerfull method !

    BUT ...

    I need to get the search result BACK to the Access form in a listbox ... BUT HOW ?

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Have you tried setting the search to a string?

  3. #3
    VBAX Regular
    Joined
    Jan 2018
    Posts
    52
    Location
    ???
    I don't get you ... please explain - I don't think this is the answer to my Q

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Try something like
    Dim result as string

    result = Shell "explorer.exe " & Chr(34) & "search-ms:query=" & WhatToSearchFor & "&crumb=location:" & WhereToSearch & Chr(34), vbNormalFocus

    msgbox result.

  5. #5
    VBAX Regular
    Joined
    Jan 2018
    Posts
    52
    Location
    ??? it just returns the number 6844 ... right now, it tells me nothing

  6. #6
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Your code just opens a new version of Explorer Search.
    What do you actually want the List box to contain?
    Can you provide a mock example?

    If you just want a list of File names I can supply VBA code that uses DIR to do so.

  7. #7
    VBAX Regular
    Joined
    Jan 2018
    Posts
    52
    Location
    I want to search through 1000's of Word documents in 10's of subfolders and show the file names for those containing a specific word or FRASE.

    The Shell-method can do it very, very fast compared to some VBA coded sub and we are talking 100-500 times faster !

    BUT ...

    I want to be able to define the search criteria (the word or the frase) in textbox on a Access form (that I can do now !)

    AND

    I want to see the result in a listbox on that same form.

    The reason ... I want to present different infos for the user when he's double clicking on the files.
    Depending on what subfolder the files is stored in, the file is related to a specific info in other parts of the whole system.

    But what's the problem now is to get the result into the listbox on that form

    Hope you understand what I mean.

  8. #8
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    I know what you want it to do, but I have googled it and can't find any information on using VBA to do it at all.
    You can copy and paste the data but that is no help.
    Sorry I couldn't help.

Posting Permissions

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