![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: India
Posts: 19
|
Dear sir,
When I add a comment for a cell, I can easily change the format of the text of it. i.e. I can change the fonts, colors, and the styles (Bold, Italics, Underlines etc.) of any selected text of it. But I want to do it programmatically and I am unable to do so. Please help me out so I can set any format for any part of text of the comment for a cell. Thanks in advance. |
|
|
|
|
|
#2 |
|
BatCoder
Join Date: Feb 2002
Location: Turkey
Posts: 764
|
wow, good question
Ok, first please visit this page and see my full code explanation there. http://www.mrexcel.com/board/viewtop...rum=2&start=16 And just change the code in section 8 like below. You will like it Private Sub ChangeCommentAction() ActiveCell.AddComment "" With ActiveSheet.Shapes(ActiveCell.Comment.Shape.Name) .TextFrame.Characters.Font.Name = "Verdana" .TextFrame.Characters.Font.Bold = True .TextFrame.Characters.Font.Italic = True .TextFrame.Characters.Font.ColorIndex = 16 .TextFrame.Characters.Font.Size = 12 .TextFrame.Characters.Font.Underline = True .Visible = msoCTrue .Select End With End Sub PS: If code gives error when you open the document then just remove this lines from thisdocument open & close module (you will be able to use Right Click on Cell-Context Menu to insert comments as you need still) remove from Workbook_Open -> Application.CommandBars("Insert").Controls("Comment").OnAction = "ChangeCommentAction" remove from Workbook_Close -> Application.CommandBars("Insert").Controls("Comment").OnAction = "" Regards Edited: Added Size, Underline, Color for font style _________________ Oz ~ TheWordExpert [ This Message was edited by: smozgur on 2002-05-25 03:11 ] |
|
|
|
|
|
#3 |
|
BatCoder
Join Date: Feb 2002
Location: Turkey
Posts: 764
|
Also try this version. More
Private Sub ChangeCommentAction() ActiveCell.AddComment "" With ActiveSheet.Shapes(ActiveCell.Comment.Shape.Name) .TextFrame.Characters.Font.Name = "Verdana" .TextFrame.Characters.Font.Bold = True .TextFrame.Characters.Font.Italic = True .TextFrame.Characters.Font.ColorIndex = 4 .TextFrame.Characters.Font.Size = 10 .TextFrame.Characters.Font.Underline = True .Fill.ForeColor.RGB = RGB(190, 190, 190) .Fill.BackColor.RGB = RGB(128, 0, 0) .Fill.TwoColorGradient msoGradientVertical, 1 .Visible = msoCTrue .Select End With End Sub Regards |
|
|
|
|
|
#4 |
|
New Member
Join Date: Mar 2002
Posts: 18
|
you can also just change the font style in your windows display properties. Excel uses this setting as the default font for comments.
under desktop/display properties/appearance, selcect "tool tip" as ITEM and set the desired font. Mav |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|