Consulting

Results 1 to 13 of 13

Thread: Search for specific word in MSWord text and Drop-Down List, Name Iteratively

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Question Search for specific word in MSWord text and Drop-Down List, Name Iteratively

    I have a word document which has drop down lists inserted in some parts of tables and main texts inside the document:





    I need to be able to search inside the document , including the drop down list options (whether the dropdown item is selected or not), for the phrase "INSERT" and "Select", and when either is found, replace them numerically with "Field 1" , "Field 2". For the numbering, 1 is the first found instance at the top of the document.
    My main current issue is no advanced or basic "Find" function includes the dropdown lists in word, how can I search them? I initially tried to do lists separately, and got this far:


    Sub LoadSchedule()
        Dim objCC As Integer 
        Dim objCL As Integer 
         
        For objCC = 1 To ActiveDocument.ContentControls.Count
         If ActiveDocument.ContentControls(objCC).Type = wdContentControlComboBox Or _
         ActiveDocument.ContentControls(objCC).Type = wdContentControlDropdownList Then
      
            For objCL = 1 To objCC.DropdownListEntries.Count
                ActiveDocument.ContentControls(objCC).DropdownListEntries(objCL).Select
              
                Selection.Find.ClearFormatting
                Selection.Find.Replacement.ClearFormatting
    
                'Here do the search inside selected area and name each found
                'area iterativley
            Next
         End If
        Next
    End Sub

    However Ideally the whole thing would be done in one loop, any and all help is appreciated.
    Last edited by elnaz_sn; 11-11-2020 at 04:05 PM. Reason: readability

Tags for this Thread

Posting Permissions

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