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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating comment with color and bold in Excel Sheet

Status
Not open for further replies.

Genotix

Programmer
Dec 16, 2004
53
0
0
NL
Hi guys,

I've got a small problem and I'm hoping you can help me out with it.
I want to put comment into a specific cell.
Inserting the comment into the cell isn't the problem.
Making the comment partly BOLD and COLORING is though.

Does anyone have a VBA script for me that fills a cell with comment that has got some lay-out like different colors and some bold text?

Thanx a lot for your help!


Linux IS userfriendly.
It's only very selective about who it's friends are.
 
Like this:
Code:
Sub FormatExcelComments()
On Error GoTo ErrHandler
  Dim oExcel     As Excel.Application
  Dim oWorkBook  As Excel.Workbook
  Dim oSheet     As Excel.Worksheet
  Dim oComment   As Excel.Comment
  
  Set oExcel = New Excel.Application
  Set oWorkBook = oExcel.Workbooks.Open("C:\MySpreadsheet.xls")
  Set oSheet = oWorkBook.Sheets(1)
  
  Set oComment = oSheet.Range("A1").AddComment("Hello World" & Chr(10) & "Am I bold?")
  
  With oComment.Shape.TextFrame
    .Characters(1, 11).Font.Bold = False
    .Characters(13, 9).Font.Bold = True
    .Characters(Len(oComment.Text)).Font.Color = RGB(255, 0, 0)
  End With
  
  oExcel.Visible = True

ExitHere:
  On Error Resume Next
  Set oComment = Nothing
  Set oSheet = Nothing
  Set oWorkBook = Nothing
  Set oExcel = Nothing
  Exit Sub
ErrHandler:
  Debug.Print Err, Err.Description
  Resume ExitHere
End Sub

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top