The following code will add a comment in a particular cell in excel worksheet.
Set oExcel=CreateObject("Excel.Application")
oExcel.Visible=True
Set oWorkBook=oExcel.Workbooks.Add
Set oWorkSheet=oWorkBook.Worksheets(1)
With oWorkSheet.Cells(1,1).AddComment
.Visible = False
.Text "Comment for Cell 1,1"
End With
oExcel.Visible=True
Set oWorkBook=oExcel.Workbooks.Add
Set oWorkSheet=oWorkBook.Worksheets(1)
With oWorkSheet.Cells(1,1).AddComment
.Visible = False
.Text "Comment for Cell 1,1"
End With
In case, you want to update the comment, use the following code:
With oWorkSheet.Cells(1,1).Comment
.Visible = True
.Text "Comment Text Changed"
End With
Read more...