Quantcast
Channel: port135.com
Viewing all articles
Browse latest Browse all 306

How to export all comments from an Excel file to Word

$
0
0

Here is the VBA macro which export the comments in the activesheet to a newly created Word file:


Sub extractComments()
Dim xComment As Comment
Dim wApp As Object
On Error Resume Next
Set wApp = GetObject(, "Word.Application")

If Err.Number <> 0 Then
Err.Clear
Set wApp = CreateObject("Word.Application")
End If

wApp.Visible = True
wApp.Documents.Add DocumentType:=0

For Each xComment In Application.ActiveSheet.Comments
wApp.Selection.TypeText xComment.Parent.Value & vbTab & xComment.Parent.Address & vbTab & xComment.Text
wApp.Selection.TypeParagraph
Next

Set wApp = Nothing
End Sub

Source. Added cell value into the code above



Viewing all articles
Browse latest Browse all 306

Latest Images

Trending Articles



Latest Images