Word VBA Assistance

I have an end user who is Visually Handicapped.  He uses Word 2016 on a daily basis.  He is pretty adept with Word, but he is having a problem with the Search and Find Feature.  He needs to be able to search, and be able to go to each hit and modify as he reviews the narrative.  Once he reviews the first hit, he would use a function key to go to the next hit.   He needs this to work in all StoryRanges, including header and footer.   He does not want the find box to popup.

I have a script which has him enter his search term, then highlight all the terms in the document, in all StoryRanges.  My dilemma is moving through the document.  In essence, he should be able to enter the search term and the word should be highlighted where he can change or keep as is.  In either case, once he makes his choice, the highlight would be removed, and the a Function key should take him to the next hit until all have been handled.  

I found the script below will do a Find and Replace, but I just need a FIND ONLY.    

Public Sub FindReplaceAnywhere()

  Dim rngStory As Word.Range
  Dim pFindTxt As String
  Dim pReplaceTxt As String
  Dim lngJunk As Long
  Dim oShp As Shape

  pFindTxt = InputBox("Enter the text that you want to find." _
    , "FIND" )
  If pFindTxt = "" Then
    MsgBox "Cancelled by User"
    Exit Sub
  End If
  TryAgain:
  pReplaceTxt = InputBox( "Enter the replacement." , "REPLACE" )
  If pReplaceTxt = "" Then
    If MsgBox( "Do you just want to delete the found text?", _
     vbYesNoCancel) = vbNo Then
      GoTo TryAgain
    ElseIf vbCancel Then
      MsgBox "Cancelled by User."
      Exit Sub
    End If
  End If
  'Fix the skipped blank Header/Footer problem
  lngJunk = ActiveDocument.Sections( 1 ).Headers( 1 ).Range.StoryType
  'Iterate through all story types in the current document
  For Each rngStory In ActiveDocument.StoryRanges
    'Iterate through all linked stories
    Do
      SearchAndReplaceInStory rngStory, pFindTxt, pReplaceTxt
      On Error Resume Next
      Select Case rngStory.StoryType
      Case 6 , 7 , 8 , 9 , 10 , 11
        If rngStory.ShapeRange.Count > 0 Then
          For Each oShp In rngStory.ShapeRange
            If oShp.TextFrame.HasText Then
              SearchAndReplaceInStory oShp.TextFrame.TextRange, _
                  pFindTxt, pReplaceTxt
            End If
          Next
        End If
      Case Else
        'Do Nothing
      End Select
      On Error GoTo 0
      'Get next linked story (if any)
      Set rngStory = rngStory.NextStoryRange
    Loop Until rngStory Is Nothing
  Next

End Sub

Public Sub SearchAndReplaceInStory(ByVal rngStory As Word.Range, _
    ByVal strSearch As String , ByVal strReplace As String )

  With rngStory.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = strSearch
    .Replacement.Text = strReplace
    .Wrap = wdFindContinue
    .Execute Replace:=wdReplaceAll
  End With

End Sub


Any assistance is appreciated.
Jeanie Francis-HayesEnterprise Applications AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aikimarkCommented:
I think you will need to create two slightly different macros. One prompts for the string to find (visible user interface, probably with a large font user form, and executes a find command.  The second one repeats the find command, looking further down the document.  After creating these two routines in a module, you would assign them to different keystroke combinations.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeanie Francis-HayesEnterprise Applications AdministratorAuthor Commented:
I have tried this.  I got the first one working great.  The second one is my issue, I am having trouble finding the highlighted Word.  I am thinking on my first find, I need to change the word to a text box, so I can find the next text box instead of a highlighed Word.  What do you think?
0
aikimarkCommented:
You need to persist a variable in the General Declarations section.  This way, the variable can be accessed by both routines.  The first routine sets it based on the user input.  The second routine uses it to repeat the find.
0
aikimarkCommented:
Solutions accepted
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.