INCLUDETEXT replace the bookmark name

D

Diane

I need to create a find/replace function that will allow me to replace the
bookmark name in the "INCLUDE TEXT" field. I've searched this site and found
an example that I'm working with, as I debug this, I see that "afield" has
the data that I need to change, all I really want to do is search for AUGUST
in the field and replace with SEPTEMBER, I can't seem to get that to work for
me, instead, I decided to search on the complete fieldcode, although I'm
getting a compiler error on my "afield.code like" statement.
Can anyone see what I'm doing wrong with this??

Dim afield As field
With ActiveDocument
For Each afield In .Fields
If afield.code = "INCLUDETEXT "\\\\NETWORK
SERVER\\dirNAME\\DIRECTORY2\\msword.doc " AUGUST" Then
afield.Select
Selection.Range.Text = "INCLUDETEXT "\\\\NETWORK
SERVER\\dirNAME\\DIRECTORY2\\msword.doc" SEPTEMBER"
End If
Next afield
End With
 
D

Doug Robbins - Word MVP

Instead of using

afield.Select
Selection.Range.Text =

use

afield.Code.Text =

--
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
 

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