update field placed in Text Box on the header and footer of a word document

F

fredrique

Hi
i have been working on a word document, where i have added a field {REF
Name} (this field refer to a bookmark in the document) into Text Box. and i
have placed the Text Box in the headerAndFooter of the document. the issue
is to get the updated field in the whole document.
i have wrote a macro that does the update, everything works fine.
the problem start when i lock(protect) the document, and i run the macro an
error happens.
the following is the code that i used

1) ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
2) Selection.HeaderFooter.Shapes("Text Box 05").Select
3) Selection.WholeStory
4) Selection.Fields.Update
5) ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

the first line checks
the 2end select the Text Box
the 3rd select the text
the 4th update
the 5th return to the mainDocument

i would realy love to get help, it means so much to me.
i'm using 2004 word,
thank you for your help
 
J

John McGhie [MVP - Word and Word Macintosh]

Yes. Your Macro needs to unprotect the document before it can update fields
in the protected section.

It can then re-protect the document. A protected document is, as its name
implies, protected from all updates.

Are you sure you "need" the protection at all? What are you protecting
against?


Hi
i have been working on a word document, where i have added a field {REF
Name} (this field refer to a bookmark in the document) into Text Box. and i
have placed the Text Box in the headerAndFooter of the document. the issue
is to get the updated field in the whole document.
i have wrote a macro that does the update, everything works fine.
the problem start when i lock(protect) the document, and i run the macro an
error happens.
the following is the code that i used

1) ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
2) Selection.HeaderFooter.Shapes("Text Box 05").Select
3) Selection.WholeStory
4) Selection.Fields.Update
5) ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

the first line checks
the 2end select the Text Box
the 3rd select the text
the 4th update
the 5th return to the mainDocument

i would realy love to get help, it means so much to me.
i'm using 2004 word,
thank you for your help

--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie <[email protected]>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 4 1209 1410
 

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