VBA code search and format text in word document - infinite loop -


i have written below code search through word document select text between words (i.e. "hide note" "hide note"). once text selected shaded. want code loop through whole document once, seem have created infinite loop. suggestions welcome!

thank you


`sub searchshade()  'start of doc selection.homekey unit:=wdstory  'start of loop until activedocument.bookmarks("\sel") = _ activedocument.bookmarks("\endofdoc")  'search selection.find.clearformatting selection.find .text = "hide note" .forward = true .wrap = wdfindstop .format = false .matchcase = false .matchwholeword = false .matchwildcards = false .matchsoundslike = false .matchallwordforms = false .execute end  'select down next hide note selection.extend selection.find .text = "hide note" .forward = true .execute selection.shading.foregroundpatterncolor = wdcolorautomatic selection.shading.backgroundpatterncolor = -603923969 end  'move down 1 para selection.movedown unit:=wdparagraph, count:=1  'loop end of document loop  end sub 

do until selection.bookmarks.exists("\endofdoc") 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -