Sorry for asking I guess. I thought someone here might know since this is a
numbering group. The solution does not need to be VBA related, it just
needs to be automatic without the user making a reference.
Oh, I was thrown off by you saying you need to do it in code.
Anyhow, in general the way to do anything without user intervention is to
use a macro aka VBA. Even custom templates require user intervention. You
are asking for something complicated--you want to find the number of items
in a list that doesn't exist yet, and that involves several steps. I think
you will need VBA to find the list, count the items, and put the answer
somewhere. Word doesn't appear to have pre-defined fields for anything like
"# of paragraphs in a certain style" or "# of entries in a numbered list,"
which is what you would need.
It's be a nice feature if the NumParas field had such switches, but since
there doesn't even seem to be a NumParas field, guess not.
> Sorry for asking I guess. I thought someone here might know since this is a
> numbering group. The solution does not need to be VBA related, it just
[quoted text clipped - 14 lines]
>>>> Insert a cross-reference to the paragraph number of the last item in the
>>>> list.
ML - 27 Feb 2005 14:04 GMT
"It's be a nice feature if the NumParas field had such switches, but since
there doesn't even seem to be a NumParas field, guess not."
Ok thanks, that is the kind of thing I was hoping for but I guess not :(
> Oh, I was thrown off by you saying you need to do it in code.
>
[quoted text clipped - 35 lines]
>>>>> the
>>>>> list.
Daiya Mitchell - 27 Feb 2005 18:02 GMT
But I bet a NumParas field is really easy in VBA. Not so sure about
limiting it to certain styles, though I would find that feature really
useful as well.
> "It's be a nice feature if the NumParas field had such switches, but since
> there doesn't even seem to be a NumParas field, guess not."
>
> Ok thanks, that is the kind of thing I was hoping for but I guess not :(
G.G.Yagoda - 01 Mar 2005 01:14 GMT
Put a bookmarked named "ListCnt" where you want to display the list
count. Then run this code:
Dim R As Range, ListCnt As Integer
Set R = ActiveDocument.Range
R.Start = R.End
Do
With R.Find
.Style = "My Style"
.Forward = False
.Execute
Select Case R.Find.Found
Case True
If R.ListFormat.ListType = 3 Or R.ListFormat.ListType = 4
Then
ListCnt = R.ListFormat.ListValue
Exit Do
Else
ListCnt = ListCnt + 1
R.End = R.Start
End If
End Select
End With
Loop While R.Find.Found
Set R = ActiveDocument.Bookmarks("ListCnt").Range
R.Text = ListCnt
ActiveDocument.Bookmarks.Add Name:="ListCnt", Range:=R