7

I have a list like this:

  1. Step one
  2. Step two
  3. Step four

As the list grows, I want a reference at the top of the page to say something like:

The last step in this document is step 3.

I want that number in bold to automatically update. Is this possible via a reference?

3 Answers 3

2

Here is a macro to do what you ask. This solution is less prone to being destroyed during document editing.

  • Create a Bookmark called MyList on the "1." of the list you want to count. (See selection in image.)
  • Create a reference to to ListCount for the result

alt text

Sub ListCountMacro()
For i = 1 To Lists.Count
If Lists(i).Range.Start = Bookmarks("MyList").Start Then Exit For
Next i

c = ActiveDocument.Lists(i).CountNumberedItems
For Each aVar In ActiveDocument.Variables
If aVar.Name = "ListCount" Then Num = aVar.Index
Next aVar

If Num = 0 Then
ActiveDocument.Variables.Add Name:="ListCount", Value:=c
Else
ActiveDocument.Variables(Num).Value = c
End If

Selection.WholeStory
Selection.Fields.Update

End Sub

You will have to run the macro each time you wish to update ListCount, so this is still not fully automatic. However, you could make the macro run whenever the document is opened, see here

1
+25

I don't think word provides this as a feature, the closest you can get is to reference "numbered" items, but adding new items to the end of the list will leave these pointing at the old end (ie, they don't update as you want them to).

However, I have a potential work-around for you: add a bookmark to a "hidden" line in the last item of the list, and reference that. It's not perfect, but might help. Please note that I am using Word 2003, but the instructions should hopefully be similar for 2007 as well.

  1. Place your cursor at the end of the last line of text in your list and press Shift+Enter.
    This will insert a line break (as opposed to a normal paragraph break), essentially adding a new line to the current row, but importantly without adding a new list number. You might also want to turn on the paragraph markers when doing this to see what is happening.

  2. With your cursor on this new line, use Tools -> Bookmarks and create a new bookmark. If you don't select any text first the bookmark will be invisible, which is probably what you want.

  3. To create a reference, use Tools -> Reference -> Cross-reference.., select Bookmark as the Reference Type and make sure you set the Insert Reference To field to be Paragraph Number.

  4. To extend this list so the last number is updated, you simply add a standard line return at the end of the last element (ie, you must insert new lines before the bookmark line). This way the bookmark is always part of the last "paragraph" in the list thanks to it's line break, so references should be numbered correctly.

Issues

  • If you add new line breaks in the wrong place (ie, after the bookmark) you list will break and if you're not careful fixing it you'll move the bookmark and mess up your references.
  • You end up with an "empty" line after your list.
1

Try this:

  1. Add a Bookmark to some text (doesn't matter which) in the final item of the list, and name it LastStep.
  2. Go to the beginning of the list and type: "The last step ... is step"
  3. Insert a Field with this code*:

    { REF LastStep \n }
    

This should add a bookmark reference to the bookmark named LastStep, and instead of including the bookmark text (which is the default), it gives the paragraph number.

*Alternatively, use the menus like this (Word 2007): Insert > Quick Parts > Field > Ref > LastStep > "Paragraph # from marked paragraph" > OK

Note: When you add additional items before the last step, the number won't update instantly on screen. Right-click on the field and choose Update Field

2
  • This doesn't address the problem at all. The whole point is that items get added after the reference is made.
    – Adam S
    Aug 3, 2010 at 16:42
  • Got it. I was thrown off from the OP where you said "step one, step two, step four," which made me think additional steps (i.e. step three) would be added in the middle. In this case I recommend DMA or subman's solutions.
    – Benj
    Aug 5, 2010 at 14:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .