Code if bookmark is found or not found

D

Dawn Bjork Buzbee

I'm working on a letter template in Word 2007 which allows users to
optionally add multiple elements to the letter and to print out different
versions (draft, memo, official, etc.).

Once optional element is a BCC entry which should not be printed on the memo
version if it was entered. Currently, the BCC entry includes a bookmark. To
remove it temporarily for printing, my code searches for the bookmark and
then cuts the text, prints the memo and then searches for the bookmark to
paste back the entry. I don't want to just undo because there may not be a
BCC entry.

I'm getting stuck on the code for the action if the bookmark is found. I've
tried IF FOUND THEN but that doesn't work. FYI, my code is below in case it
is helpful:

'Find bcc bookmark to select and cut bcc text; not used for memo but used
for other copies

Selection.GoTo What:=wdGoToBookmark, Name:="bcc"

If Found Then
Selection.MoveDown Unit:=wdLine, Count:=4, Extend:=wdExtend
Selection.Cut
End If

' Print out memo
ActiveDocument.PrintOut

'Find bcc bookmark to select and paste bcc text;

Selection.GoTo What:=wdGoToBookmark, Name:="bcc"

If Found Then
Selection.TypeParagraph
Selection.PasteAndFormat (wdPasteDefault)
End If

Thanks in advance,
 
D

Doug Robbins - Word MVP

With ActiveDocument
If .Bookmarks.Exists("bcc") Then
'Do something
Else
'Do something else
End If
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top