Return or find outline list number

M

MarceepooNu

I haven't been able to find any of the following:

1. A field that would return the number of the paragraph in a numbered
outline list. e.g., assume you're using heading 1 style (with a number that
automatically appears on the left in every paragraph). Assume that this is
your sectond paragraph, so it look like this:
"2. Hello. This is paragraph number 2 in an outline numbered
paragraph."
Is there a field that I can use to insert the second "2"?

I am trying to automate a lawyer's complaint form. For example, paragraph
No. 95 (Numbered Heading Style 1) will read as follows: "Plaintiff hereby
re-alleges and incorporates herein by reference paragraphs 1 - 94 of this
Complaint, inclusive, as though fully set forth herein."

2. Is there vba code that I could use to search for paragraph number 2 (in
heading 1), and copy its text to a string variable?

Thanks,

MarceepooNu
 
L

Lene Fredborg

Q1
You can insert the second number as a cross-reference to the heading number.

Q2
Maybe you can use the following macro. The code iterates through all
paragraphs that are numbered or bulleted. If the number is the one you search
for and if, at the same time, the style is correct (in the code below set to
Heading 1 – change to the relevant style), then the text of the paragraph is
stored in the variable strHeading. Note that the format of the number string
must be as in your document – in the code below, “2.†is searched – i.e. you
must include a period if used in the document.


Dim oPara As Paragraph
Dim strHeading As String

For Each oPara In ActiveDocument.ListParagraphs
If oPara.Range.ListFormat.ListString = "2." And oPara.Style =
"Heading 1" Then
strHeading = oPara.Range.Text
'Remove paragraph mark from string
strHeading = Left(strHeading, Len(strHeading) - 1)
'Stop now
Exit For
End If
Next oPara

The code could be inserted in a function with the number string as a
parameter and - if different styles are involved, also add the style name as
a parameter. Then you can call the same function whenever you need to find a
the text of a numbered item.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
M

MarceepooNu

1. Thank you. Your response is VERY very much appreciated.
2. I think your answer to the second question will help me to accomplish
what I need to do. I'll work on it and report back to you.
3. Regarding the first question, I want to figure out how to automate
getting the {ref } field to cross-reference to the heading number. One
possibility that occurred to me is to create a macro that would update all
reference fields that contain some peculiar text string that I would use to
identify these fields.
---A. First, the macro would search for {ref } fields (although I confess
that I'm not where I'll find the vba to tell Word to search for fields, and
then to search their contents).
---B. Next, the macro would insert a bookmark (somewhere in the paragraph)
and the bookmark's contents would be a random number or text string
equivalent.
---C. Next the macro would go inside the {ref } field and insert the code
to cross-ref the bookmark.

What do you think? I bet there's a simpler way.

Thanks again for your time. Much appreciated.

MarceepooNu
 

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