How To use Data from a form field in word as a document footer.

itkadmin
itkadmin used Ask the Experts™
on
I am working on building a template document for reports.
On the cover of the report, We have a space to enter title and a date

These fields were created using Rich Text Controls in the Design Mode under Developer.

The fields are called title and date.

I would like the information the staff member enters on the cover page to populate the footer on subsequent pages with whatever was entered into the form fields on the cover page.

Is there a way to do this? If so, how?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
One way to do that is to use a macro. Place two text boxes in the footer (Developer Tab - Control Box - ActiveX Controls - Text Box). Go to the visual basic editor (Alt+f11), highlight "This Document" and select View Code. Paste in the following:

Sub UpdateFields()
  Me.TextBox1.Value = ActiveDocument.ContentControls(1).Range
  Me.TextBox2.Value = ActiveDocument.ContentControls(2).Range
End Sub

You may have to modify the ContentControls numbers (1) to match your title and date fields.
Flyster
Retired
Top Expert 2012
Commented:
Another way would be to use StyleRef fields.

Create two new styles from the current style of each Content Control, e.g. Styel1 & Style2, Set the style of each control to one of each style.

In the footer, place two StyleRef fields (Insert tab, Text group, Quick Parts dropdown, Field... Item) and set each StyleRef field to refer to the relevant style.

Author

Commented:
Both solutions worked. I went with the second one as it doesn't use macros. I liked the first better because it provides more control, but it uses macros. The problem with that is some staff use the online version of word which doesn't work well with macros and some staff were thrown off by having to enable macros in a document.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial