Export comments and corresponding text from MS Word to Excel

alimair

New Member
Joined
Jul 30, 2014
Messages
12
Hello,

I'm looking for a way to export comments from MS Word and display them in Excel alongside the corresponding highlighted text, with one text/comment pair per row. I think a macro should be able to achieve this pretty easily but I'm not very good at that sort of thing. Can anyone help?

Thanks,

Ali
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Awesome. Glad we got there :)

/AJ

Hi Adam,
This Macro helped a lot. However I had the need to exporting the section heading as well while I export the comments. Any pointers to how to do it easily <that is, following your approach :) >
Thanks a lot,
NSD
 
Upvote 0
Hi all

I'm bringing up this old thread. I used a slightly modified version of this macro a while back, but now after upgrading to Office 2013 I can't use it as I'm getting an out of range error.

Furthermore, I would like to develop the script so that I can choose multiple files and insert them all. I already made another macro that print the name of the Word file to cell A1 in the sheet.

Can anyone help me with the problem and my need?

I paste the current code that I have here below, please let me know if anything is unclear.

Code:
Option Explicit




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 = .Range.Text
                    destSheet.Cells(rowToUse, colToUse + 1).Value = .Scope.Text
                    destSheet.Columns(2).AutoFit
                End With
                
                rowToUse = rowToUse + 1
                
            Next thisComment
            
            destSheet.Cells(1, colToUse).Value = Left(myDoc.Name, 4)
            'Put name of interview object in cell A1
            
            destSheet.Cells(1, colToUse + 1).Value = ActiveDocument.Words.Count
            'Put the number of words in cell B1
            
            Set myDoc = Nothing
            myWord.Quit
            
            colToUse = colToUse + 2
            
        Next varFile
    
    End If
        
End Sub


Public Sub PrintFirstColumnOnActiveSheetToSheetName()


    ActiveSheet.Name = ActiveSheet.Range("A1")


End Sub
 
Upvote 0
Hello AJ.
Since you've bee so helpful with this issues I wanted to ask you for another issues that occured when I tried running this macro.
Set destSheet = ThisWorkbook.Sheets("Sheet1")
This row was highlighted in the code. Is there somethig I need to change which I did not catch?
Thanks for ur help.
Eleni
 
Upvote 0
Hello AJ.
Since you've bee so helpful with this issues I wanted to ask you for another issues that occured when I tried running this macro.
Set destSheet = ThisWorkbook.Sheets("Sheet1")
This row was highlighted in the code. Is there somethig I need to change which I did not catch?
Thanks for ur help.
Eleni
So, I recognize that the post was made 5 years ago, but in case it helps anyone, I think that Eleni's issue is that the VBA code needs to be put into an Excel workbook.
I believe that Eleni may have put the VBA code into the VBA of a Word document instead.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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