Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm creating a Word 2003 Template with some fields in it as these are the only bits of text that should change (things like Company Name, Address etc.).

Now, if the person using the form fills in the Company Name field at the top (which I've created as a Text Form Field), how can I reference that value elsewhere in the Template?

share|improve this question
    
Please see updated answer and let me know if you have any problems. –  James Aug 11 '10 at 18:15

1 Answer 1

Try this:

  • Right click on the field then click Properties.
  • Ensure field is named as something you can remember
  • Tick the Calculate on Exit check box
  • Click OK to close the dialog
  • Click Insert->Reference->Cross-reference...
  • Check that Reference type is set to Bookmark and Insert reference to is set to Bookmark text
  • Select the field whose value you want to use
  • Click OK

Note that this may not work for all field types.

If you want these references in the header they will not update automatically. To make them update automatically when user exits the source field you need to create a macro:

  • Select Tools->Macro->Macros... from main menu
  • Enter UpdateHeader in Macro name text box
  • Click Create
  • Using the VBA editor that pops up, replace the default code with the following:

    Sub UpdateHeader()
    Dim i As Integer
    
    
    'exit if no document is open
    If Documents.Count = 0 Then Exit Sub
    Application.ScreenUpdating = False
    
    
    'Get page count
    i = ActiveDocument.BuiltInDocumentProperties(14)
    
    
    If i >= 1 Then 'Update fields in Header
    ActiveDocument.Sections(ActiveDocument.Sections.Count) _
    .Headers(1).Range.Fields.Update
    End If
    
    
    Application.ScreenUpdating = True
    End Sub
    
  • Click the save icon in the VBA editor and close it

  • Right-click the source field (i.e. one that contains value entered by user) and click Properties.
  • Select UpdateHeader from the list of macros to run on exit
  • Click OK
share|improve this answer
    
Thanks for the help. This nearly works except that I have to manually update the Cross-Reference field by right-clicking and Update Field. I confirmed that I have Calculate on Exit checked. Any idea why? –  Richard Bysouth Aug 9 '10 at 9:36
    
Are any of the fields outside of the document body (e.g. header) by any chance? If so then they will not update immediately. This is a limitation of how Word works. But if you print or save I think they should get updated. I'm not sure of a good workaround, there are probably some macros available on the internet. –  James Aug 9 '10 at 9:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.