Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Capturing data from the results of a Dialog (VBA/Word/2003 SP2)

    From Word; using the File | Open then Tools | Search | Advanced combination of menu and subsequent tab selection, I am able to get a list of Word and Excel files that contain a given text string. However I have been frustrated in my attempts to capture this information in a similar manner through VBA.

    I now plan to:
    1. <LI>Open a Word file in the folders that are within the interrogation area;
      <LI>Search the document for the selection of search terms and take note of the success or failure;
      <LI>Close the file
      <LI>Log the results and take any other appropriate action
      <LI>Open the next Word file and repeat until all files have been tested
    This will certainly be less efficient than my original optimistic approach. Is there a better approach that jumps to mind?

    After completion of the Word Interrogation, Excel files will need to be interrogated as well. As I see it; I will be writing code in Excel to achieve the same end. Please advise If a more efficient approach exists.

    Better yet; Does anyone know of a technique to capture the results of my original optimistic approach in Word? (File | Open then Tools | Search | Advanced )

    Many thanks in advance.
    Regards
    Don

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

    Re: Capturing data from the results of a Dialog (VBA/Word/2003 SP2)

    You can use the FileSearch object for this. Look it up in the VBA help. Here is an example:

    Sub AdvSearch()
    Dim i As Integer
    With Application.FileSearch
    .FileTypes.Add msoFileTypeExcelWorkbooks
    .FileTypes.Add msoFileTypeWordDocuments
    .LookIn = "C:SomeFolder"
    .SearchSubFolders = True
    .TextOrProperty = "Wells"
    .MatchTextExactly = True
    If .Execute > 0 Then
    For i = 1 To .FoundFiles.Count
    Debug.Print .FoundFiles(i)
    Next i
    End If
    End With
    End Sub

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Capturing data from the results of a Dialog (VBA/Word/2003 SP2)

    Hans
    Thank you. Words cannot express my gratitude,
    Regards
    Don

Posting Permissions

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