UPDATE FIELD CODE IN MSWORD VBA

A

Alok

Hi,
Please tell me how can we update the fields with a new value.
Is there any other command than SET to update the same fieldcode.

When i have to update the same field with a new value i have to run the SET
command which ultimately creates a same field code with new value but DOESN'T
OVERWRITE TO THE EXISTING FIELDCODE.

Example:

I have set the field code with the value

Public Sub SetBookmark(objDoc As Document, sBookmark As String, sValue As
String)

If objDoc.Bookmarks.Exists(sBookmark) Then
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"SET " & sBookmark & " " & sValue & ""
Else
MsgBox sBookmark & "Does not Exist"
End If
End Sub
 
D

Doug Robbins

You would be better off to use document variables and docvariable fields.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
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