copy comments to word

  • Thread starter Thread starter news
  • Start date Start date
N

news

Hi,
I'm having difficulties writing code to copy comments to word.
I'm confused on the "Selection" and/or "Range" Values and how to use them
in this situation.

I need to be able to highlight a range of cells in excel...
Then, copy all the comments in the selected area to a word document.

I have ran across code that will copy the whole workbooks comments but that
is not needed for this.

Thanks for all the help.
Strikker
 
The following code will copy the comments in the selected range to Word:

'==============================
Sub CopySelectionCommentsToWord()
Dim rng As Range
Dim c As Range
Dim WdApp As Object

On Error Resume Next
Set WdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Err.Clear
Set WdApp = CreateObject("Word.Application")
End If

Set rng = Selection.Cells.SpecialCells(xlCellTypeComments)

With WdApp
.Visible = True
.Documents.Add DocumentType:=0
For Each c In rng
.Selection.TypeText c.Address _
& vbTab & c.Comment.Text
.Selection.TypeParagraph
Next
End With

Set WdApp = Nothing

End Sub
'====================================
 
Back
Top