Reply
 
Thread Tools Display Modes
  #1   Report Post  
Think.Ng.
 
Posts: n/a
Default Forms and Getting Macros to work

Hello,

I attached macros to a form so that fields can be updated automatically in
the Table of Contents and Footer sections of a document.

When the form was built in XP everything worked fine. Then, when I used it
in Windows 2000, the macros and assigned macro keys did not work. I tweaked
the form for Windows 2000 and it half worked - the Footer Fields would
automatically re-populate but the TOC wouldn't refresh. Then, I tested the
form on a colleague's machine (she also had Windows 2000) and the macro keys
didn't work at all although she could manually run the macro - the Footer
fields did refresh, but, again, no luck with the TOC.

Please can someone advise on how to get a TOC to refresh via a macro. I want
the form to remain protected as much as possible. I tried

activedocument.updatetableofcontentsfull

but nothing happend.

Also, why would we have different experiences if we're both using Windows
2000?

Any pointers would be appreciated. Valerie Ng.

  #2   Report Post  
Graham Mayor
 
Posts: n/a
Default

In order to get REF fields in a header/footer to update automatically from a
form field, you need to force an update with a macro run on exit from the
form field. (Styleref fields don't need such encouragement - they will
reflect the content of the styles, though checking the calculate on exit
check box of the relevant field would help). There is a variety of macro
code around to effect updates eg -

Sub Update()
Dim oField As Field
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter
Dim oTOC As TableOfContents
For Each oTOC In ActiveDocument.TablesOfContents
oTOC.Update
Next oTOC
For Each oSection In ActiveDocument.Sections
For Each oHeader In oSection.Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
oField.Update
Next oField
End If
Next oHeader
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
oField.Update
Next oField
End If
Next oFooter
Next oSection
End Sub

but I tend to use the all encompassing code listed on my web site at
http://www.gmayor.com/installing_macro.htm

Save the form as a template and set Word's macro security to trust all
installed templates and add-ins.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Think.Ng. wrote:
Hello,

I attached macros to a form so that fields can be updated
automatically in the Table of Contents and Footer sections of a
document.

When the form was built in XP everything worked fine. Then, when I
used it in Windows 2000, the macros and assigned macro keys did not
work. I tweaked the form for Windows 2000 and it half worked - the
Footer Fields would automatically re-populate but the TOC wouldn't
refresh. Then, I tested the form on a colleague's machine (she also
had Windows 2000) and the macro keys didn't work at all although she
could manually run the macro - the Footer fields did refresh, but,
again, no luck with the TOC.

Please can someone advise on how to get a TOC to refresh via a macro.
I want the form to remain protected as much as possible. I tried

activedocument.updatetableofcontentsfull

but nothing happend.

Also, why would we have different experiences if we're both using
Windows 2000?

Any pointers would be appreciated. Valerie Ng.



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:49 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"