LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Add Comments to Word

I have the following code to copy out all Comments on the active sheet to
word, ok first of all I don't need the $ before the column and row, next is
it possible to also list a value from a specific column, in other words my
column B is always a list of people so if I add a comment on E4 it should
add the value of B4, if I have a comment on H8 it should add B8 and so on,
perhaps maybe I could be done on the other code I have which copies all
comments to a new sheet, the only drawback with that second code is that I'd
rather open a new excel workbook Vs inserting a new sheet.

CODE ONE
Sub CopyCommentsToWord()

Dim cmt As Comment
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

With WdApp
.Visible = True
.Documents.Add DocumentType:=0

For Each cmt In ActiveSheet.Comments
.Selection.TypeText cmt.Parent.Address _
& vbTab & cmt.Text
.Selection.TypeParagraph
Next
End With

Set WdApp = Nothing

End Sub
----------------------------------------------------------------------------
-------
CODE TWO
Sub ShowCommentsAllSheets()
'modified from code
'posted by Dave Peterson 2003-05-16
Application.ScreenUpdating = False

Dim commrange As Range
Dim mycell As Range
Dim ws As Worksheet
Dim newwks As Worksheet
Dim i As Long

Set newwks = Worksheets.Add

newwks.Range("A1:E1").Value = _
Array("Sheet", "Address", "Name", "Value", "Comment")

For Each ws In ActiveWorkbook.Worksheets
On Error Resume Next
Set commrange = ws.Cells.SpecialCells(xlCellTypeComments)
On Error GoTo 0

If commrange Is Nothing Then
'do nothing
Else

i = newwks.Cells(Rows.Count, 1).End(xlUp).Row

For Each mycell In commrange
With newwks
i = i + 1
On Error Resume Next
.Cells(i, 1).Value = ws.Name
.Cells(i, 2).Value = mycell.Address
.Cells(i, 3).Value = mycell.Name.Name
.Cells(i, 4).Value = mycell.Value
.Cells(i, 5).Value = mycell.Comment.Text
End With
Next mycell
End If
Set commrange = Nothing
Next ws

'format cells for no wrapping, remove line break
newwks.Cells.WrapText = False
newwks.Columns("E:E").Replace What:=Chr(10), _
Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False

Application.ScreenUpdating = True

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying comments from Word to Excel Simone Excel Discussion (Misc queries) 3 January 13th 09 07:14 PM
Importing Word Comments etchief Excel Discussion (Misc queries) 0 October 7th 08 10:31 PM
Export excel comments to word Ali Excel Discussion (Misc queries) 4 July 23rd 08 03:18 PM
Importing Comments from MS Word Ashish Excel Discussion (Misc queries) 0 April 28th 08 06:21 AM
Question - Excel Comments to Word Footnotes Ngentot Excel Discussion (Misc queries) 0 May 18th 06 02:15 AM


All times are GMT +1. The time now is 11:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"