Using Fields and Properties in Word 2007 Documents

Microsoft Word provides an extensive list of properties available for user. However, every now and then there is a need for a special property, especially when fields are used. Or so I thought.
Actually, fields aren’t used that often as one who uses them could expect. Although almost everyone has at one point in time used fields (Total number of pages, current page – these are actually fields), most of the users aren’t aware of this.

How to insert a field in a document:

In order to insert a field in a document, follow these steps:

  1. Position the cursor at the place in document where you want to insert the field
  2. Go to Insert > Quick Parts > Fields
  3. Select from the list of available fields (left pane) and select one of their properties

Microsoft Office Word Fields

That’s it. This way you can insert Author property, Create Date, Date Saved, etc.

How to create a new property and use it as a fields.

However, I found on a couple of occasions that I cannot find the property I need. For example, I needed something like Customer, Project, Technology… things that simply weren’t there. What I did – I create custom properties and used them as fields. Here is how:

  1. Click Microsoft Office Button > Prepare > Properties
  2. Document Properties menu and window are displayed. From Document Properties menu, select Advanced Properties
  3. Click on Custom tab
  4. In the Name field, type the name of your custom property (Customer in this example)
  5. Select Text from the Type drop down list
  6. Type in Customer’s name in the Value field
  7. Click Add
    1. Microsoft Office Word Customer Field
      Note: If you later want to edit this property, Add button will change to Modify when you select the property from the list of properties and change the value. It will not be available until you change it.
  8. Now position the cursor at the place in document where you want to insert the field
  9. Go to Insert > Quick Parts > Fields
  10. Select from the list of available fields (left pane) DocProperty
  11. Locate Customer property in the right pane and select it. Click OK.

Microsoft Office Word Customer Field Codes

That’s it.

Note: Although Word automatically updates fields, it seems that custom properties have to be updated manually. In order to do this, just right click on the field and select Update Field
Keywords: Word 2007 Property fields custom tips tricks

Tags: , ,

11 Responses to “Using Fields and Properties in Word 2007 Documents”

  1. Bassam Says:

    Hello, do you know how to synchronize the value of the custom property with field value, I mean, If I have a field that is related with a custom property, and I changed the field value, is there any option that automatically synch the new value of the field to the custom property?
    thanks

  2. Petar Miljkovic Says:

    Hello Bassam and thank you for your question.
    I don’t think that this can be done with fine tuning the settings in Word 2007; at least I wasn’t able to figure it out. However, I’ve put together a macro that does the trick
    Sub UpdateCustomProperties()

    ‘ UpdateCustomProperties Macro
    ‘ created by Petar Miljkovic’
    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
    ActiveWindow.ActivePane.View.Type = wdNormalView
    Else
    ActiveWindow.View.Type = wdNormalView
    End If
    Selection.WholeStory
    Selection.Fields.Update
    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
    ActiveWindow.ActivePane.View.Type = wdPrintView
    Else
    ActiveWindow.View.Type = wdPrintView
    End If
    End Sub

    You can perhaps run this macro before you close the document in order to make sure that everything gets updated and you don’t have to worry about it. In order to do that, you should just call this macro on closing:

    Private Sub Document_Close()
    Call UpdateCustomProperties
    End Sub

    Hope it helps,
    Petar

  3. Nava Says:

    Hi
    It is fanstastic. Very much useful.

    Great.

    Regards
    Nava

  4. Per Norrgren Says:

    Hi, this macro is very useful. Thanks for posting this.
    One more request please.
    In MSWord2007 is there any way to add my custom field to the little “field entry form” that comes visible when you go Prepare>Properties? There are fields like customer name, ID number, etc. that I fill in for each document and it would be great to have them all in one place.
    thanks and regards
    Per Norrgren

  5. Goran Says:

    Hi Petar,
    Nice post. Since you are good with macros I was wondering if you could help me a bit here.

    Let’s say I have three fields in my doc – footer section (Field1=BusinessReqDoc, Field2=ProjectOne, Field3=Version3). All there field values are entered regularly using the property fields. Is there any way that on saving this document I can retrieve all three field values and concatenate them together AND create a file name on the fly…:)
    So, on CTRL+S I would get a window pop and the file name would be pre-populated with value of those three fields…something like that…(just to avoid typing file name again)…

    FileName = BusinessReqDocProjectOneVersion3.doc

    There may not be solution for this but I just was wondering if it can be done…

    Thanks for your help,
    Goran

  6. Petar Miljkovic Says:

    @Per Norrgren: I don’t think it is possible. The default view after you go to Prepare>Properties is Document properties. I don’t think that this can be customized. If you are using a document management system, like Sharepoint, this view can change. You can see all the properties by going to Prepare>Properties > Advanced Properties

  7. Petar Miljkovic Says:

    @Goran
    Sure there is.
    I will not go into details, as this can be easily tweaked, but I might write a separate blog entry on how it can be tweaked.
    You will want to know the exact names of your custom properties as those are needed for the macro to work.
    Let’s say you named them as in the explanation you provided above.
    Field1 Field2 Field3

    The simplest macro that will do the trick is this:

    Sub SaveAsUsingCustomDocumentProperty()

    ‘ SaveAsUsingCustomDocumentProperty Macro
    ‘ created by Petar Miljkovic

    Set Field1 = ThisDocument.CustomDocumentProperties(“Field1″)
    Set Field2 = ThisDocument.CustomDocumentProperties(“Field2″)
    Set Field3 = ThisDocument.CustomDocumentProperties(“Field3″)
    ActiveDocument.SaveAs FileName:=Field1 & Field2 & Field3

    End Sub

    Note that this will not prompt the File > Save As dialog, but will use the document properties. Of course, you will want to make sure that the properties are updated, so you can combine the two macros together.

    Hope this helps.

  8. Jerusha Says:

    Petar-
    I think your most recent comment is probably what I need, but as I’m new to macros I can’t get it to run.

    My vision: I’ve built a template in Word 2007, such that when you open a doc based on the template, has a field for the date created that populates in the header. I’ve also got a field for the user to fill in which describes the topic of the document. Ideally, I’d like it to work such that when the user hits “save” for the first time (or “save as”), the suggested file name is pulled from these fields as “YYYY-MM-DD TOPIC”. I haven’t been able to figure this out.

    As a poor cheat, I filled in the title field in document properties on the template, hoping that when a doc was open based on the template, the suggested title in the “save as” dialog box would be that which I added to the template document properties. However, it’s not working (and I’ve tried many ways). On the template doc properties, I’ve got “YYYY-MM-DD Notes” (but without the quotes) hoping that then when I opened a new doc, the suggested title would also be “YYYY-MM-DD Notes”. Not ideal, but at least it would remind me to follow the naming format. However, the suggested file name is given as “YYYY” with the rest truncated.

    Any suggestions? Thanks so much.

  9. Goran Says:

    Excellent. Thanks Peter. This really helps…Appreciate it.
    Goran

  10. custom macros Says:

    [...] what it calls Activities’, custom macros which perform a series of commands such as turning on …Using Fields and Properties in Word 2007 Documents …Microsoft Word provides an extensive list of properties available for user. However, every now and [...]

  11. admin0 Says:

    Hello Jerusha,
    You are on a good track. Word actually does use Title property to suggest the file name. For example, when you open a new Word document and just type in a couple of pages of text, you will get a suggested file name created of the beginning several words. Word takes those words, uses them to populate Title property if it is blank and then suggests file name.
    I’m seeing the similar behavior as you do. For some reason, Word doesn’t seem to like the “-” in the file name. Although you can populate the Title property using format “YYYY-MM-DD” it will truncate everything after the “-”.
    Here is a brief macro I put up that should do the trick with “YYYYMMDD” format. You should probably tweak it a bit to get it you close to wanted results.

    Sub SetDocumentTitle()

    Dim YYYYMMDD As String
    Dim NameToSuggest As String

    Set AnyCustomProperty = ThisDocument.CustomDocumentProperties(“Topic”)
    YYYYMMDD = CStr(Format(Now(), “yyyyMMDD”))
    NameToSuggest = AnyCustomProperty & YYYYMMDD
    With Dialogs(wdDialogFileSummaryInfo)
    .Title = NameToSuggest
    .Execute
    End With
    End Sub

    regards,
    Petar

Leave a Reply