' This macro will export all the comments in the word doc to a new word doc.
' U can save the word doc as .txt.
' Change the extension to .csv
' Open the doc with excel and u have exported your comments to excel
Sub ExportComment()
Dim s As String
Dim cmt As Word.Comment
Dim doc As Word.Document
For Each cmt In ActiveDocument.Comments
s = s & cmt.Initial & cmt.Index & "," & cmt.Range.Text & vbCr
Next
Set doc = Documents.Add
doc.Range.Text = s
End Sub
Hey Jay,
ReplyDeleteGreat macro, it works. Thanks.
Thanks from me too, Jay. That was a big help!
ReplyDeleteHello,
ReplyDeleteThank for this macro, but is it possible to extend it's functionality by exporting also marked texts in Word document, which are commented?
In other words, I need marked texts in one Excel column and comments in second.
to export marked texts in Word document use Comment.Scope
ReplyDeleteGreat macro, it helps me a lot. Save my time.
ReplyDeleteGreat Macro! Is there a way to also export what section, page, line# the comments is in? Thanks!
ReplyDeleteI would like to thank you too - good job.
ReplyDeleteYou have saved me HOURS of time with this code. Thank you so much.
ReplyDeleteAwesome. Short, sweet, effective. Thanks a lot!
ReplyDeleteHow do we use this macro? Do we need to add this code somewhere to make it work?
ReplyDeleteRegards
V
Hey V,
ReplyDeleteThis is a code for macros in word. Find out how to create macro in word. Just google and you will find your way.
Thanks,
Jay
Thanks Jay, that was very useful to export comments from word to excel.
ReplyDeleteExactly what I needed :-)Thanks.. Saved me a lot of time and effort. Any suggestions on how I can get Line and Page number as well..
ReplyDeleteThanks,
--O
Awesome, thanks
ReplyDeletePerfect. Thanks.
ReplyDeleteSuperb macro,
ReplyDeletePlease can u tell me how can I get comments along with the sections commented upon???
Please help me ASAP....
Thank you very much it still works in the new Word. It worked perfectly :D
ReplyDeleteGreat macro, thanks Jay!!
ReplyDeleteReally helpful ... thanks a lot ..
ReplyDeleteThanks Jay that saved me a bit of time.
ReplyDeleteI have also updated to include page number;
' This macro will export all the comments in the word doc to a new word doc.
' U can save the word doc as .txt.
' Change the extension to .csv
' Open the doc with excel and u have exported your comments to excel
Sub ExportComment()
Dim s As String
Dim cmt As Word.Comment
Dim doc As Word.Document
'ActiveDocument.Repaginate
For Each cmt In ActiveDocument.Comments
cmt.Scope.Select
iCurrentPage = Selection.Information(wdActiveEndPageNumber)
s = s & iCurrentPage & "," & cmt.Author & " (" & cmt.Initial & ")," & cmt.Date & "," & cmt.Range.Text & vbCr
Next
Set doc = Documents.Add
doc.Range.Text = s
End Sub
This works so well. Thank you so much. Microsoft should pay you to have this feature, and shame on them for not incorporating it as a standard procedure.
ReplyDeleteReally cool...it's just slash down my work into half ;)
ReplyDeleteThanks!
Here is the version of exporting with marked text....
Sub ExportComment()
Dim s As String
Dim cmt As Word.Comment
Dim doc As Word.Document
For Each cmt In ActiveDocument.Comments
s = s & cmt.Initial & cmt.Index & "," & cmt.Range.Text & "," & cmt.Scope & "," & cmt.Parent & vbCr
Next
Set doc = Documents.Add
doc.Range.Text = s
End Sub
-thirilog
HI Jay,
ReplyDeleteHow can I include the page number? Thanks!
Amazing macro that worked without any further editing. As others have said, it just saved me hours...and it will likely be used very heavily from now on. THANK YOU.
ReplyDeleteThanks Jay, worked like a charm. Now I'll sit back and relax for a bit and pretend it took me a long time to extract out all those comments :)
ReplyDeleteHi...
ReplyDeletehere's a version for selecting the ActiveDocument, and copying all of the comments out into a table in a new document... I have added 4 columns, and they are Comment index, date+time, the text you highlighted (scope.text) and the text of the comment (range.text)
Sub ExportComment()
Dim s As String
Dim cmt As Word.Comment
Dim doc As Word.Document
Dim workBk As Word.Document
Set workBk = ActiveDocument
Set doc = Documents.Add(Visible:=True)
Dim myRange As Range
Set myRange = doc.Range(0, 0)
Dim myTable As Table
Set myTable = doc.Tables.Add(Range:=myRange, NumRows:=workBk.Comments.Count, NumColumns:=4)
Dim i As Integer
i = 1
For Each cmt In workBk.Comments
myTable.Cell(i, 1).Range.Text = cmt.Index
myTable.Cell(i, 2).Range.Text = Format(cmt.Date, "dd/MM/yyyy HH:mm")
myTable.Cell(i, 3).Range.Text = cmt.Scope.Text
myTable.Cell(i, 4).Range.Text = cmt.Range.Text
i = i + 1
Next
End Sub
Best regards
Oliver
How would I go about changing the first column to the page number the comment appears on?
DeleteWhat about adding a column for Reviewer Name and page number?
ReplyDeleteGreat, just what I needed. Thanks!
ReplyDeleteThis is great. Just what I needed for document analysis/coding!
ReplyDeleteHi,
ReplyDeletethis one gives you the page numbers as well. When it asks for an output file name, use something like "out.txt".
It's inspired by the Power Point Comments Extractor provided at http://www.pptfaq.com/FAQ00900_Export_comments_to_a_text_file_-PowerPoint_2002_and_later-.htm
Sub ExportComment()
Dim s As String
Dim cmt As Word.Comment
Dim doc As Word.Document
Dim sFilename As String
oldpage = -1
For Each cmt In ActiveDocument.Comments
If (oldpage <> cmt.Scope.Information(wdActiveEndPageNumber)) Then
s = s & vbCrLf & "Page: " & cmt.Scope.Information(wdActiveEndPageNumber) & vbCrLf
s = s & "======================================" & vbCrLf
End If
' cmt.Initial & cmt.Index & ": " &
s = s & cmt.Range.Text & vbCrLf
s = s & "--------------" & vbCrLf
oldpage = cmt.Scope.Information(wdActiveEndPageNumber)
Next
sFilename = InputBox("Full path to output file:", "Output file")
If Len(sFilename) > 0 Then
WriteStringToFile sFilename, s
SendFileToNotePad sFilename
End If
End Sub
Sub WriteStringToFile(pFileName As String, pString As String)
' this writes the text out to a file
Dim intFileNum As Integer
intFileNum = FreeFile
Open pFileName For Output As intFileNum
Print #intFileNum, pString
Close intFileNum
End Sub
Sub SendFileToNotePad(pFileName As String)
' This opens the file in notepad
Dim lngReturn As Long
lngReturn = Shell("NOTEPAD.EXE " & pFileName, vbNormalFocus)
End Sub
Best regards
Thomas
thank you for this easy way to export comments
ReplyDeleteBrilliant. Thank you!
ReplyDeleteThank you for the quick and easy macro folks. Appreciate the knowledge share for this.
ReplyDeleteThanks Jay and every one else. It was a great help.
ReplyDeleteWith little bit of experimentation with the codes supplied above, I managed to put together another version of this to suit my requirements as below
Exporting to a Table of 5 columns Page number, Reviewer Initial with comment number, Date, Commented Text and Comment in a new document
Sub ExportComment()
Dim s As String
Dim cmt As Word.Comment
Dim doc As Word.Document
Dim workBk As Word.Document
Set workBk = ActiveDocument
Set doc = Documents.Add(Visible:=True)
Dim myRange As Range
Set myRange = doc.Range(0, 0)
Dim myTable As Table
Set myTable = doc.Tables.Add(Range:=myRange, NumRows:=workBk.Comments.Count, NumColumns:=5)
Dim i As Integer
i = 1
For Each cmt In workBk.Comments
cmt.Scope.Select
iCurrentPage = Selection.Information(wdActiveEndPageNumber)
myTable.Cell(i, 1).Range.Text =”Page” & iCurrentPage
myTable.Cell(i, 2).Range.Text = cmt.Initial & cmt.Index
myTable.Cell(i, 3).Range.Text = Format(cmt.Date, "dd/MM/yyyy HH:mm")
myTable.Cell(i, 4).Range.Text = cmt.Scope.Text
myTable.Cell(i, 5).Range.Text = cmt.Range.Text
i = i + 1
Next
End Sub
Manesh
Thank you very much! This was very helpful.
DeleteThis is excellent.
ReplyDeleteGreat code, thanks for putting this up! I was wondering if it was possible to make this code also include the section heading number from a multi-tier heading outline?
ReplyDeleteThis code worked like a charm. It will be a fantastic help with my committee's comments on my doctoral dissertation draft.
ReplyDeleteTHANK YOU!
A HUGE thank you to all who contributed! You have just saved my bacon!
ReplyDeleteHello, can the full name vice the initial be added to the last macro?
ReplyDeleteHello, very interesting post!
ReplyDeleteIs there a way to insert the generated table at the end of the read document? in a new page?
Thanks in advance.
Great and I have a dandy provide: How Long Do House Renovations Take house renovation edmonton
ReplyDelete