|
|
|
|
|
|
|
|
|
Word
|
Extract Comment Text and Place as Footnotes
|
|
|
Ease of Use
|
Intermediate
|
|
Version tested with
|
2002
|
|
Submitted by:
|
fumei
|
|
Description:
|
Extracts the comments from the text in the document and places them as Footnotes on the page.
|
|
Discussion:
|
This could be modified for a number of uses. It checks each page for comments, and if there are any, extracts the text of each comment individually. In this example, the text is placed into separate footnotes. However, they could be placed into an array, per page, or diverted into another document. Use #1: you have a number of reviewers, and you wanted to automate pulling out just a specific reviewers comments; Use #2: you could add bookmarks to point to the specific location of the comment, and pull the comment (and only the comment text) out, with a reference back to the paragraph, and place those into a new document
|
|
Code:
|
instructions for use
|
Sub MakeCommentsFootnotes()
Dim aDoc As Document
Dim i As Integer
Dim cCount As Integer
Dim strComment As String
Dim r As Range
Dim var
Dim var2
Set aDoc = ActiveDocument
Selection.HomeKey Unit:=wdStory
i = 1
On Error Resume Next
For var2 = 1 To aDoc.BuiltInDocumentProperties(wdPropertyPages)
' select current page
Set r = aDoc.Range(Start:=aDoc.Bookmarks("\page").Start, _
End:=aDoc.Bookmarks("\page").End)
' get a count of comments on the page
cCount = r.Comments.Count
If cCount > 0 Then
' collapse selection to keep it on same page
Selection.Collapse direction:=wdCollapseStart
For var = 1 To cCount
' select LAST comment on page as
' footnotes list in reverse order
aDoc.Comments(i + (cCount - 1)).Range.Select
' set string for comment text
strComment = Selection.Text
' close the comments pane to allow editing
ActiveWindow.ActivePane.Close
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
' use current page range to set footnote
With aDoc.Range(Start:=aDoc.Bookmarks("\page").Range.Start, End:= _
aDoc.Bookmarks("\page").End)
With .FootnoteOptions
.Location = wdBottomOfPage
.NumberingRule = wdRestartContinuous
.StartingNumber = 1
.NumberStyle = wdNoteNumberStyleArabic
End With
.Footnotes.Add Range:=Selection.Range, Reference:=""
End With
Selection.TypeText Text:=strComment
i = i - 1
Next ' next comment on current page
Else
End If
' go to next page
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
i = ((aDoc.Comments.Count - cCount) + 1)
Next
Set aDoc = Nothing
End Sub
|
|
How to use:
|
- Copy the code above.
- Open the Visual Basic Editor by Alt-F11, or Tools > Macro > Visual Basic Editor (VBE).
- From the menu, choose Insert-Module to insert a module into the file in which you want the code to work.
- Paste the code into the code window at right.
- Hit the Save diskette button.
- Close the VBE.
|
|
Test the code:
|
- Create a document with any number of comments.
- Run the code by Tools-Macro-Macro and double-click MakeCommentsFootnotes.
|
|
Sample File:
|
ExtractComments.zip 8.68KB
|
|
Approved by mdmackillop
|
|
This entry has been viewed 74 times.
|
|
|