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



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




Thanks!