Conditional ListNum

S

Steve B

I have a simple document that uses ListNum to number each paragraph.

1. Paragraph...
2. Paragraph...
3. Paragraph...
4. Paragraph...

Then I introduce an "if" statement that inserts text from another
document via "includeText".

1. Paragraph...
2. Paragraph...
3. {IF {MERGEFIELD MONTH}= "APRIL" "{INCLUDETEXT "C:\\SPRING"}" ""}
4. Paragraph...

Text works fine. But, if the inserted text includes a ListNum, then
the numbers lose their sequence.

Any ideas on how to keep the numbers in sync regardless of whether the
"if" text is inserted or not inserted.

Thanks,
Steve B
 
W

Word Heretic

G'day (e-mail address removed) (Steve B),

ListNum fields carry no list id. If you were to use seq nums you could
use a different LT for each text chunk.


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Steve B reckoned:
 
B

Bruce Brown

Steve -

One easy fix would be to change the LISTNUM fields that number the
paragraphs to AUTONUM fields. The two fields do not effect each
other's values.

This macro will do it for you. However, it must be run *before* the
text is inserted so it doesn't catch all the inserted LISTNUM fields
as well, resulting in a replay of the same problem.

Dim F As Field, R As Range
Set R = Selection.Range
For Each F In ActiveDocument.Fields
If F.Type = wdFieldListNum Then
F.Select
Selection.Delete
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"AUTONUM ", PreserveFormatting:=False
Selection.Move
End If
Next
R.Select
ActiveWindow.View.ShowFieldCodes = False

How to install a macro:
http://word.mvps.org/faqs/macrosvba/CreateAMacro.htm
 
W

Word Heretic

G'day (e-mail address removed) (Bruce Brown),

Elegant!

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Bruce Brown reckoned:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top