Consulting

Results 1 to 10 of 10

Thread: Interacting the Search Dialogue Box

  1. #1

    Interacting the Search Dialogue Box

    Hi
    Any one can help me, how to interact with Search Dialogue box of Window in VBA (Excel) coding?

    I am able to display it from the coding and also can set the default folder, but I am looking to set the "Text to be searched" through code, or if possible just using the "Search Dialogue" box without its User Interface(i.e. in hidden way)....

    Sailesh Kr Mishra
    Proud To Be An Indian

  2. #2
    Is there any one who can help me out of this???

    Need this urgently....
    Sailesh Kr Mishra
    Proud To Be An Indian

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Greetings,

    I am unclear as to what you are looking to do. Could you post a small example workbook showing what you have so far? .xls format would be preferable, as some of us still have older versions.

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Would the .Find method of a Range object do what you want?

  5. #5

    Please find below

    Thanks for the reply, Please find attached the workbook (.xls), kindly change the path of folder in cell "B4" of sheet "Sailesh Main" and then click on the button.

    It brings the "Search Dialogue Box" and then the user has to enter "Text to be searched" and clicks "Search" of the dialogue box and finally window returns all the files containing the "Text to be Searched" in the Folder and sub folders in the standard search box.

    However I don't want to show "Search Dialogue Box", only want to use its functionality in the VBA code.

    My Scenario is to find a "Text/String" in all the files in the folder and in sub folders in the folder (number of files is approximately 3000), so using .find will be very slow, hence I am looking to use API for this.

    Please let me know if I missed something ....
    Sailesh Kr Mishra
    Proud To Be An Indian

  6. #6
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    If you are not using 2007 try filesearch
    [VBA]
    Sub dosearch()
    With Application.FileSearch
    .NewSearch
    .LookIn = "C:\AAA" '<==== Change to suit
    .TextOrProperty = InputBox("Enter search string")
    .SearchSubFolders = True
    .Filename = "*.xls"
    .FileType = msoFileTypeAllFiles
    If .Execute() > 0 Then
    MsgBox "There were " & .FoundFiles.Count & _
    " file(s) found."
    For i = 1 To .FoundFiles.Count
    Cells(i, 1) = .FoundFiles(i)
    Next i
    Else
    MsgBox "There were no files found."
    End If
    End With
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7

    Using 2007

    Thanks for replying,
    However I am using 2007, with windows xp and vista, planning to upgrad to office 2010.

    Kindly revert what I can use in this scenario...

    Sailesh Kr Mishra
    Proud To Be An Indian

  8. #8
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    I am afraid that I do not see a wb attached. Use the <Go Advanced> button below the Quick Reply box. Then scroll down a bit in the new window and use the <Manage Attachments> button. Fairly self-explanatory thereafter.

    Mark

  9. #9
    Thanks for reply ...,I am not sure why the manage attachment option is not working, please see the codes below:-Option Explicit'API declaration for the windows &quot;Search Results&quot; dialogPrivate Declare Function ShellSearch& Lib &quot;shell32.dll&quot; _ Alias &quot;ShellExecuteA&quot; (ByVal hwnd As Long, _ ByVal lpOperation As String, _ ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, _ ByVal nShowCmd As Long) Private Const SW_SHOWNORMAL = 1Sub ShowWindowsSearchDialog_API()' Specified drive to Search Dim szSDrive As String Dim i As Integer szSDrive = Sheets(&quot;Sailesh Main&quot.Cells(4, 2).Value ShellSearch 0, &quot;find&quot;, szSDrive, &quot;&quot;, &quot;&quot;, SW_SHOWNORMALEnd SubThis macro is then assigned to a button, in sheet &quot;Sailesh Main&quot; and default folder is picked using &quot;Sheets(&quot;Sailesh Main&quot.Cells(4, 2).Value&quot;.Please see if this serves the purpose...
    Last edited by Mis_Sailesh; 04-04-2010 at 11:18 PM.
    Sailesh Kr Mishra
    Proud To Be An Indian

  10. #10

    Please find the attachement

    Attachment 3214

    Please find the attachement
    Sailesh Kr Mishra
    Proud To Be An Indian

Posting Permissions

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