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
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