Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comments in Excel Cells via VBA

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I am trying to programmatically add some comments to Cells in Excel 97 worksheets usign VBA with codes similar to the following:
Code:
With xlsheet.Range("A11").AddComment
    .Text "The Text I wanted as comment"
    .Author "My Project name"
End With

I face the following problems:-
1) Compile error on .Author
a)Using
Code:
.Author = "My Project name"
doesn't work either
b)Nor does
Code:
Set .Author= "My Project name"

2) "The Text I wanted as comment" appears in BOLD in the comment box, which normally happens just for Author name non-programatically.

So How could I set comments such that the Author name appears properly and the text appears non-bold??
I want the comments to be
My Project name
The text I wanted as comments
[sig][/sig]
 
The Author is a ReadOnly string, therefore it can not be set. As far as the formatting, I am not sure. [sig][/sig]
 
Ok,
.Author cannot be set, but as what is actually used is the value of Application.UserName. You can change the value of .UserName just before your comment adding code (read it into a variable before changing it so you can reset the UserName to its original value).
However, you should be able to get away with the following:

Range("I10").AddComment
Range("I10").Comment.Text Text:="My Project Name:" & Chr(10) & "The text I wanted as comment"

Excel should then be able to sort out the bold and normal text (bold appears for text on top line automatically). [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top