Out in the field (code)

When it comes to field codes, we find several different camps.

First, there's the group who says, "We need more documentation, with better examples."

Then, there's who says, "You don't need to know about field codes. They are so old fashioned."

Another group says, "What are these funny bracket things and gray places in my document?"

Finally, there is apparently a very large group of people who use Word and have never knowingly encountered a field code.

Do any of these sound familiar?

What is a field code?

Field codes provide a way to customize your Word document manually. That sounds like hard work, but the field codes also give you an inside look at some of the ways that you can customize a page number or a table of contents. (Really—those are fields.)

The results of a field code might look like this:

but if you press ALT+F9, the actual code might look like this:

The \o, \h, \z, and \u are switches that provide specific information. For example, \h specifies that the table of contents entries should be hyperlinks so that you can click the page number and go to that page in the document.

Word has a long list of field codes that you can add by clicking the Insert tab, clicking Quick Parts (in the Text group), and then clicking Field. Click the field that you want to insert, click the Field Codes button, and then click Options to see a list of all possible switches, with a description of each.

But do you want to know more?

We're always plotting and planning and sifting through customer data—yes, from you—to figure out what to document next. Where do we want to put our resources? We got off to a slow start on field codes because the basic information, the switches and properties, didn't change from Word 2003 to Word 2007—and all of the Word 2003 information is online.

Plus, Word 2007 has some very nice user interface features to do the heavy lifting. That's fine until someone wants to customize a part of their document. And that's when a little knowledge of field codes can help.

Now, we've added some articles on field codes to the Word 2007 Help, and customer comments are telling us that those articles are less helpful than we want them to be. Why? Do they assume too much context? Too much knowledge of field codes and other technical things, such as switches and parameters? Or do people get to those articles by mistake, when really they want a much easier way to get the job done?

If we added more background information, would more people use field codes? Is that even a good thing?

In keeping with the spirit of inquiry, I'd like to do a really short survey:

  • Do you use field codes?
  • If not, have you ever tried to use a field code?
  • What would help you most?

Yes, I have a lot of questions, and your answers are appreciated. The more information we get, the better help we can provide.

-Joannie Stangeland

Office Blogs Comments

Comments: (23) Collapse

  • Right now I'm trying to find out how to create a bookmark that encapsulates the result from a field code... ActiveDocument.Bookmarks.Add "PJM1", ActiveDocument.Fields(3).Code Doesn't quite do it. The .Code range refers to the field content. The field result seems to be .Code.Start-1 to .Code.End+3 So, it would be helpful if this were documented somewhere. Is it always -1,+3?? If you have a definitive answer, an e-mail to pmartinsen at gmail dot com would be great! Keep up the good work,

    paul.

  • I am using Word 2003 and downloaded a Microsoft template for creating Invoices. I would like to create cell references in the Invoice to an Excel spreadsheet so that various cells in Excel can populate the Invoice automatically. Is there a way of doing this? Or, should I create an Access database and create an Invoice report? Thank you.

  • I'd either like a lot more flexibility in the ability format individual parts of the text generated by a style or more documentation on how to do it (if it is already possible). For example, I would like to be able create multiple tabs in a TOC that is generated using styles. It was interesting to ready you say, "Then, there's who says, "You don't need to know about field codes. They are so old fashioned." Well, then show me a better way to get exactly what I need as efficiently I can, and without using a mouse, if possible. I'm certainly capable with moving with the times, but I need efficiency and documentation. Why not document everything you can? Nobody has to read it, but it is there if you need it. And while you're documenting, put in a little paragraph about the style seperator! Thanks!

  • I support corporate clients using to Word 2007 (loathed by the vast majority of my clients). In 2003 it was easy to disable an entire document's field codes by going to Tools>Options>General tab> clear the Field Codes check box. Is there a SIMPLE way to do the same in 07? We do not want them on by default, nor do we want to have to disable on each document, just OFF!

  • I need to extract all sentences in an arbitrary document that have been revised, both in the original version without tracking and in the version with tracking (strikeout/underline, colored, etc.). I have it working; however, the field codes are giving me fits. The codes don't start at Code.Start and end at Code.End. Neither does the result. I must know these things in order to construct the original string and decorate the tracked changes in a new document (that does not have field codes). Specifically, I must be able to associate every printable character in the source document sentence with the position in a string or in the output document. With codes taking a random space, I cannot do the job. Please define what you mean by the properties Start and End for Revisions, Field.Code, and Field.Result. Displaying the field codes doesn't work because they only show what the developer thinks someone might want to see, not what is actually there. You must know this stuff because your revision tracking is right on the money!

  • You don't need to know until you need to know.  You decide you want to do something, then you research how to do it.  I want to bold cross references some way other than manually formatting them with either character styles or the bold command, both of which may or may not be lost when the field code is updated.  That is when you hit a brick wall.  Is it possible? No-one knows.  If it is, how?  Again, no-one knows.  But more importantly we need this very clunky, badly designed and out of date feature to be brought up to date.  It hasn't changed in how many upgrades?  And how long has it been really nasty?  FrameMaker had it fixed before the turn of the century, so why has MS not managed to fix it?

  • Hi, I am very new in using the Field Code concept in word 2007.

    Need some help, thjanks in advance.

    The problem is, we have created the autotext/ribbon component for the page numbering (which asks the number to start the page numbering, its a pop-up). But whenever we are navigate to that component (like the insert or any other menu) while loading itself the pop-up asking for the user input will come. The pop should come only when we click/select that perticular object.

    Any idae/solution on how to correct this functionality.

  • I use field codes, and I wish there was more documentation. For example, SEQ field codes behave really oddly if used inside an equation created by equation editor to make numbered equations. I haven't found anything about it (although maybe I'm looking in the wrong place!).

    I like the fact that the user has the ability to access the back-end mechanics of how Word creates sequences etc, and there are still good UI approaches to do the same thing. It gives a lot of flexability to the process. Perhaps the help files could start with the simple UI appreach and then have a more advanced section at the end explaining how to do the same thing with field codes, and how to edit an already generated field code.

    Thanks for all your hard work.

Comments

Comments: (loading) Collapse