You can update fields with a macro even in a protected document. In its simplest form, the following line of code can be used:
ActiveDocument.Fields.Update
Depending on the needs of your document, something more sophisticated may be required, though.
Dear Stefan Blom,
As I said earlier, my word document has password and protected from editing except some exception in entire word document. I am using below codes for update my fields.
Sub ChangeLinkPath()
Dim rg As Range
Set rg = ActiveDocument.Range
rg.TextRetrievalMode.IncludeFieldCodes = True
With rg.Find
.Text = "<original path and file name>"
.Replacement.Text = "<new path and file name>"
.Execute Replace:=wdReplaceAll
End With
ActiveDocument.Fields.Update
End Sub
But whenever I execute this, it will showing run time "4605" error because of my word document is password protected. Can anyone have solution for this ?
- I want to update all fields in word document,
- All the fields have to update in password protected mode
Thanking You,
Afzal