Friday, April 2, 2010

VBScript - Adding Comments to an Excel Spreadsheet

VBScript - Adding Comments to an Excel Spreadsheet

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)

k = 1
For i = 1 to 5
For j = 1 to 3
objWorksheet.Cells(i,j) = k
k = k + 1
Next
Next

objWorksheet.Cells(1, 1).AddComment "Test comment."
objWorksheet.Cells(2, 3).AddComment "This is another test comment."

[Via]