Exporting comments

H

Havelock12

I have a series of documents containing masses of comment balloons. I need to
take all of the information out of these comments for analysis. So I'm
looking for a way to export all of the comments at once, preferably to a
table in a new document.

Does anyone know how to do this? I've posted in some other tech forums but
no one seems to know. Even being able to select all of the comments
simultaneously and copying and pasting (to a new doc) would do. Also, could
it be that these comments are stored in an array somewhere?

Many thanks,
 
J

Jay Freedman

Havelock12 said:
I have a series of documents containing masses of comment balloons. I
need to take all of the information out of these comments for
analysis. So I'm looking for a way to export all of the comments at
once, preferably to a table in a new document.

Does anyone know how to do this? I've posted in some other tech
forums but no one seems to know. Even being able to select all of the
comments simultaneously and copying and pasting (to a new doc) would
do. Also, could it be that these comments are stored in an array
somewhere?

Many thanks,

The following macro is an adaptation of one I posted for tracked changes at
http://groups.google.com/group/microsoft.public.word.docmanagement/msg/2188cc26e005fa03?hl=en.
See http://www.gmayor.com/installing_macro.htm if you need instructions.

Run the macro while one of your documents is open. It will create another
document containing a table, with a row for each comment showing date/time,
page number, line number, and the text of the comment. If you need it, it
would be possible to make the macro extract the formatted text of the
comment, the name of the person who made the comment, and several other bits
of information.

Sub ExportComments()
Dim srcDoc As Document, destDoc As Document
Dim oCom As Comment
Dim oTbl As Table
Dim nRows As Long


Set srcDoc = ActiveDocument
Set destDoc = Documents.Add
destDoc.Sections(1).Headers(wdHeaderFooterPrimary) _
.Range.Text = "Comments in " & _
srcDoc.FullName


Set oTbl = destDoc.Tables.Add(Range:=destDoc.Range, _
numrows:=1, numcolumns:=4)
nRows = 1
With oTbl
.Cell(1, 1).Range.Text = "Date & Time"
.Cell(1, 2).Range.Text = "Page"
.Cell(1, 3).Range.Text = "Line"
.Cell(1, 4).Range.Text = "Comment"

For Each oCom In srcDoc.Comments
.Rows.Add
nRows = nRows + 1
.Cell(nRows, 1).Range.Text = _
oCom.Date
.Cell(nRows, 2).Range.Text = oCom.Scope.Information( _
wdActiveEndAdjustedPageNumber)
.Cell(nRows, 3).Range.Text = oCom.Scope.Information( _
wdFirstCharacterLineNumber)
.Cell(nRows, 4).Range.Text = oCom.Range.Text
Next oCom

.Rows(1).HeadingFormat = True
End With
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
H

Havelock12

That worked perfectly. Thanks!

Jay Freedman said:
The following macro is an adaptation of one I posted for tracked changes at
http://groups.google.com/group/microsoft.public.word.docmanagement/msg/2188cc26e005fa03?hl=en.
See http://www.gmayor.com/installing_macro.htm if you need instructions.

Run the macro while one of your documents is open. It will create another
document containing a table, with a row for each comment showing date/time,
page number, line number, and the text of the comment. If you need it, it
would be possible to make the macro extract the formatted text of the
comment, the name of the person who made the comment, and several other bits
of information.

Sub ExportComments()
Dim srcDoc As Document, destDoc As Document
Dim oCom As Comment
Dim oTbl As Table
Dim nRows As Long


Set srcDoc = ActiveDocument
Set destDoc = Documents.Add
destDoc.Sections(1).Headers(wdHeaderFooterPrimary) _
.Range.Text = "Comments in " & _
srcDoc.FullName


Set oTbl = destDoc.Tables.Add(Range:=destDoc.Range, _
numrows:=1, numcolumns:=4)
nRows = 1
With oTbl
.Cell(1, 1).Range.Text = "Date & Time"
.Cell(1, 2).Range.Text = "Page"
.Cell(1, 3).Range.Text = "Line"
.Cell(1, 4).Range.Text = "Comment"

For Each oCom In srcDoc.Comments
.Rows.Add
nRows = nRows + 1
.Cell(nRows, 1).Range.Text = _
oCom.Date
.Cell(nRows, 2).Range.Text = oCom.Scope.Information( _
wdActiveEndAdjustedPageNumber)
.Cell(nRows, 3).Range.Text = oCom.Scope.Information( _
wdFirstCharacterLineNumber)
.Cell(nRows, 4).Range.Text = oCom.Range.Text
Next oCom

.Rows(1).HeadingFormat = True
End With
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
W

WaggaRMP

Havelock12
I'm having trouble replicating the code - for some reason I keep getting
eror messages when trying to run it - if you have it available from teh
Visual Basic Editor - could you please (pretty please) send it to me at
rpillow(at)csu.edu.au
many thanks
WaggaRMP
 
O

Opinicus

This is a macro for doing this that was given to me by someone in one of
these groups:

<quote>
Sub ListAllComments()
'
' ListAllComments Macro
'
Dim doc As Word.Document
Dim docComments As Word.Document
Dim rng As Word.Range
Dim cmt As Word.Comment

Set doc = ActiveDocument
Set docComments = Documents.Add
Set rng = docComments.Range
For Each cmt In doc.Comments
rng.Text = cmt.Range.Text & vbCr
rng.Collapse wdCollapseEnd
Next cmt
End Sub
</quote>

It creates a new file containing all the comments in the original file.
 

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