View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] akh2103@gmail.com is offline
external usenet poster
 
Posts: 28
Default Finding and selecting text in word from excel

Hello--I have written a simple macro trying to find and select certain
text in a word document (it is part of a larger project). When the
macro is finished running, I would like word to have the first instance
of the text selected. However, the following code is not doing the job.
I am sure I am missing something simple. Can anyone help?
-Abe

Sub find()

Set wdapp = GetObject(, "Word.Application")
Set wddoc = wdapp.ActiveDocument

With wddoc.Content.find
.Text = "Q1"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchAllWordForms = False
.Execute (findtext = "Q1")
End With

End Sub