PDA

View Full Version : new bookmark value is not updating the referencing fields



zahir4job
04-05-2012, 01:27 AM
I have four bookmarks and many fields are referenced to these bookmarks I want to update the text of the bookamrks each time I run the macro and eventually all the fields referring to the bookmarks should be updated with the new value I tried many ways to update the bookmark text and update the fields but the fields are getting updated only once with a new document later on its not reflecting. following is the code i used. Please help I am new to macro coding. Thanks in advance.

Dim bmRange As Range
Set bmRange = ActiveDocument.Bookmarks("BankNameCover").Range
bmRange.Text = "Value1"
ActiveDocument.Bookmarks.Add _
Name:="BankNameCover", _
Range:=bmRange
Set bmRange = Nothing ' Repeat this three more times for other three bookmarks

For Each myField In ActiveDocument.Fields
myField.Update
'myField.Locked = True
Next myField

Please help thanks in advance.

fumei
04-05-2012, 09:28 AM
ActiveDocument.Fields.Update?

zahir4job
04-12-2012, 12:42 AM
yes, I am using following code to update all the fields in the document
For Each myField In ActiveDocument.Fields
myField.Update
Next myField

Actually I have four bookmark names and I am referencing these bookmark name in the fields like this for example :
{REF MandateLetterDate \*MERGEFORMAT }
through macro I am updating the 4 bookmark text value and calling the above mentioned code to update the fields with the new bookmark text value but its not happening. please help Thanks Fumei