Insert a formatted comment in excel

Hi again…

Tryed to insert formatted comment, seems to be impossible. searched the forum, both 4.5 and above, same thing in the internet, didn’t find any solution, so a decied to ask the pro’s

Set xlApp = CreateObject(“Excel.Application”)

Between these two lines happens a lot and I don’t think it has anything to do with the comment line.

xlSheet.Cells(rows,cols).AddComment commentString$

Tryed this one

xlapp.ActiveCell.Comment.Shape.TextFrame.Characters.Font.size=9

tryed with “with” ,samething

I get error msg, objective variable not set

Anyone who got any solution for this one?

Subject: Insert a formatted comment in excel

When running it through the debugger, where does the error occur? I can tell you for a fact that this line doesn’t work:

xlSheet.Cells(rows,cols).AddComment commentString$

you need to pass your commentString variable as a parameter:

xlsheet.Cells(rows,cols).AddComment(commentString)

once commentString is dimmed, you don’t need to have the $.

You can not use the form as it shows in the Visual Basic editor in excel. Parameters must be passed in parentheses…:= and the form of that method in help will NOT work.

brandt

Subject: RE: Insert a formatted comment in excel

Well beleave it or not but xlSheet.Cells(rows,cols).AddComment commentString$ works, never mind.

My question was in fact, is there any way to format comments, I mean font, color etc.

Subject: RE: Insert a formatted comment in excel

might be useful for others,xlsApp.Range(rangeValue).AddComment(“Test”)

xlsApp.Range(rangeValue).Comment.Visible = True

xlsApp.Range(rangeValue).Comment.Shape.Select

xlsApp.Selection.Font.Bold = False

xlsApp.Selection.Font.Size = 10

xlsApp.Selection.Font.Name = “Arial”

xlsApp.Range(rangeValue).Comment.Visible = False