Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 08-18-2020, 09:09 PM
Charles Kenyon Charles Kenyon is offline new to vba - go to end of sub Windows 10 new to vba - go to end of sub Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,464
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
 

Tags
nubie, search and replace



Other Forums: Access Forums

All times are GMT -7. The time now is 11:21 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft