Deleting and Recreating a Numbered List

D

DartmanX

I am attempting to create a technical document to consolidate UML use
case diagrams within a document. This document has multiple sections,
including a section which actors for the use cases are listed. In order
to automate the document, I am attempting to protect the document from
changes, except via a custom toolbar.

The problem I have run into (probably the first of many) involves a
simple numbered (outline) list of the Actors listed in the Use cases.
When a new actor is added, I want to recreate the list and add the new
Actor (or add the new Actor to the end of the existing list).

I have inserted a bookmark at a section which will have a numbered
list, named "ActorNames", and move the cursor there by calling:

ActiveDocument.Bookmarks("ActorName").Select

However, I need to be able to select the entire numbered list (if it
exists, if not, create a new one), delete it, and recreate it when a
new actor is added to the list.

Any help would be appreciated.
 
D

Doug Robbins - Word MVP

The following can be easily modified so that it applies the numbering in
ascending order rather than the reverse:

' Macro created 12/02/2006 by Doug Robbins to apply/re-apply reverse
sequential numbering

Dim i As Long, Numrange As Range

Set Numrange = Selection.Range

With Numrange

For i = 1 To .Paragraphs.Count

If IsNumeric(.Paragraphs(i).Range.Characters(1)) Then

With .Paragraphs(i).Range

While IsNumeric(.Characters(1))

.Characters(1).Delete

Wend

.Characters(1).Delete

End With

End If

.Paragraphs(i).Range.InsertBefore .Paragraphs.Count - i + 1 & vbTab

Next i

End With

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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