Word – How to copy value from one field to another in Word 2003

microsoft wordtemplates

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?

Best Answer

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
Related Question