Check Word 2007 bookmark content and do something if it exists -


is possible search content inside bookmark , if exists, something.

for example, if there word document bookmark named bookmark1. enclosing text bookmark1 created highlighting the text "entered text goes here". want create macro check see if text inside bookmark changed, , if not, delete text, bookmark, section break before it.

the code below except deletes bookmark if text different because looking name of bookmark, not content.

if activedocument.bookmarks.exists("bookmark1") = true     activedocument.bookmarks("bookmark1").select     selection.delete     selection         .endkey unit:=wdstory         .typebackspace         .delete     end end if 

i want if statement like: if text inside bookmark1 = "entered text goes here" stuff below, else quit.

ideas anyone?

word 2007.

the below should work if document set how think is, otherwise need have play around it:

'testtxt default text in bookmark (assuming not including paragraph mark in bookmark) dim testtxt string: testtxt = "enter text here" 'dmrng range of the bookmark looking @ dim bmrng range: set bmrng = thisdocument.bookmarks("bookmark1").range   if bmrng.text = testtxt         'start beginning of bookmark - 1 (as character before hand should section break?!)         bmrng.setrange start:=bmrng.start - 1, end:=bmrng.end         bmrng.delete end if 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -