Export comments and corresponding text from MS Word to Excel - URGENT

gwadse

New Member
Joined
Nov 10, 2016
Messages
2
Hello guys,

Please someone help me.
I need to extract +- 300 comments from Word and put them in an excel file.

I've found this code in a previous post:
[h=1][/h]

Public Sub FindWordComments()
'Requires reference to Microsoft Word v14.0 Object Library


Dim myWord As Word.Application
Dim myDoc As Word.Document
Dim thisComment As Word.Comment

Dim fDialog As Office.FileDialog
Dim varFile As Variant

Dim destSheet As Worksheet
Dim rowToUse As Integer
Dim colToUse As Long

Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
Set destSheet = ThisWorkbook.Sheets("Sheet1")
colToUse = 1

With fDialog
.AllowMultiSelect = True
.Title = "Import Files"
.Filters.Clear
.Filters.Add "Word Documents", "*.docx"
.Filters.Add "Word Macro Documents", "*.docm"
.Filters.Add "All Files", "*.*"
End With

If fDialog.Show Then

For Each varFile In fDialog.SelectedItems

rowToUse = 2

Set myWord = New Word.Application
Set myDoc = myWord.Documents.Open(varFile)

For Each thisComment In myDoc.Comments

With thisComment
destSheet.Cells(rowToUse, colToUse).Value = .Scope.Text
destSheet.Cells(rowToUse, colToUse).AddComment Text:=.Range.Text
End With

rowToUse = rowToUse + 1

Next thisComment

destSheet.Cells(1, colToUse).Value = "Comments from " & myDoc.Name

Set myDoc = Nothing
myWord.Quit

colToUse = colToUse + 1

Next varFile

End If

[h=1][/h]I always get the error user-defined type not defined

This is what I've ticked on in the reference:

[url]http://prntscr.com/d5k1ms
[/URL]

Normally the structure in excel should be:

Title/Subtitle - Comment - Who - Date

Please someone help me with this :confused::confused::confused::confused:

Thanks!
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top