View Single Post
  #2   Report Post  
Charles Kenyon
 
Posts: n/a
Default

I haven't tested the following with a TOC field but it should work.

Sub TOCFieldUpdate()
' Written by Charles Kyle Kenyon 27 January 2005
' Field Updater - TOC fields
Dim oField As Field
On Error Resume Next
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldTOC Then
oField.Update
End If
Next oField
End Sub

Try putting this in your module and calling it from your unprotect /
reprotect procedure or simply add the code to your procedure. Hope this
helps.
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

"La La Lara" wrote in message
...
Hi guys

I am a bit stuck. I have a form which has a ToC in it. I have used the
code at
http://word.mvps.org/FAQs/MacrosVBA/...lfResetOff.htm.
which works fine to uprotect the doc, then I can manually left-click by
the
ToC, hit F9 and it updates, then the macro will reprotect the form without
losing any of the info in the form fields. It works a treat.

BUT....! It would be even more seamless to the user if I could add a bit
of
VB code that will unlock the form, *automatically update the fields*, then
reprotect the form without losing any of the form field info (so that the
user can simply click an icon on the toolbar which will do all this
instead
if him/her having to go to the ToC and cliking F9)

I did try to cobble together some code but it wouldn't work.

Can anyone help?