Problem copying numbered list entries using VBA

N

Neil Humphries

I need to copy using VBA paragraphs which include numbered list entries from
multiple documents to a summary document and retain the original numbering.
What currently happens is:
3.4.1.2 Some text
3.4.1.3 More text
in the original becomes
1.0.0.0 Some text
1.0.0.1 More text
in the summary.

How can I keep the original numbering (make it static rather than dynamic).
I need the original numbering so the user can reference back to the original
location in the originating documents.

The original documents seem to have implemented the numbering using both
fields and autolist entries, so I may need two approaches.

I have code to search all the documents in a folder and extract the
appropriate paragraphs to the summary document.

Partial code to find search term and select the paragraph that it is in:
Do While .Execute(findText:=arrFindList(I))
Selection.Font.Bold = True
Set rPara = Selection.Range 'The found text
rPara.Bold = True
rPara.MoveStart wdParagraph, -1
rPara.MoveEnd wdParagraph, 1
iFoundIt = iFoundIt + 1
'Add paragraph with found text to output file
InsertFoundText sSearchFileName, sMyName, rPara
Selection.EndOf Unit:=wdParagraph, Extend:=wdMove
Loop
and

Sub InsertFoundText(sSourceFile As String, sInsertFile As String, rFoundText
As Variant)
'Called from FindAndListHeader and FindAndListStory
Dim rngEndOfDoc As Range
Documents(sInsertFile).Activate
Set rngEndOfDoc = ActiveDocument.Paragraphs.Last.Range
With rngEndOfDoc
.InsertParagraphAfter
.InsertAfter rFoundText
End With
Documents(sSourceFile).Activate
End Sub
 
P

Pesach Shelniitz

Hi Neil,

In your Do While loop with a call to Execute, you could use the
Selection.Range.ListFormat.ListString property to retrieve the number as it
appears in the source file and then modify the string retrieved from the
Selection.Range.Text property.
 
P

Pesach Shelnitz

Hi Neil,

In your Do While loop with a call to Execute, you could use the
Selection.Range.ListFormat.ListString property to retrieve the number as it
appears in the source file and then modify the string retrieved from
Selection.Range.Text.
 
N

Neil Humphries

Thanks for the input. Unfortunately, I am not sure how to do what you
suggest. Do I need to extract the numeric portion of the selection first,
process it and then join the revised numeric portion with the rest of the
selection?
 

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