View Single Post
 
Old 08-18-2020, 09:09 PM
Charles Kenyon Charles Kenyon is offline Windows 10 Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

I forgot to execute the find to fill the found property.
.Execute

Code:
Sub SearchTest() 
    ' Charles Kenyon 
    ' If word not found skip rest of macro
    Const strWORDTOFIND As String = "Test"
    With ActiveDocument.Range.Find
      Let .Text = strWORDTOFIND
      .Execute
      If .Found = False Then GoTo endofsub 
     End With 
    ' Rest of macro here
     MsgBox strWORDTOFIND & " is present." 
endofsub: 
End Sub
Reply With Quote