Microsoft KB Archive/160956

From BetaArchive Wiki

Article ID: 160956

Article Last Modified on 11/23/2006



APPLIES TO

  • Microsoft Excel 97 Standard Edition



This article was previously published under Q160956


SUMMARY

By default, the text of a cell comment contains the user name in the first line of the comment. There is no built-in feature that automatically disables inserting the user name in the comment text. However, you can use a Visual Basic for Applications macro to insert a blank comment. This article contains a macro example that inserts a blank comment in the active cell.

NOTE: The user name that is displayed in the comment is that same name that appears in the User Name box when you click Options on the Tools menu, and then click the General tab.


MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

Preventing the User Name from Appearing in a Comment

To prevent the user name from appearing in a comment, use a Visual Basic for Applications macro to create the comment. To insert an empty comment in the active cell, use the following steps:

  1. Start the Visual Basic Editor (press ALT+F11) and type the following macro code in a new module (click Module on the Insert menu):

    Sub New_Comment()
    
        ActiveCell.AddComment ("")
        ActiveCell.Comment.Visible = True
    
    End Sub
                        
  2. Select a cell in a worksheet.
  3. Run the New_Comment macro.

    Microsoft Excel inserts a new comment, without the user name, for the active cell.
  4. Click in the text area of the comment, and then type the text of the comment.

Inserting a Blank Comment with a Gradient Fill

The following example macro inserts an empty comment for the active cell. This comment is formatted with a gradient fill pattern and uses a different AutoShape and an italic bold font face.

  1. Type the following code in a module:

    Sub Fancy_Comment()
       
        ActiveCell.AddComment ("")             'Create the comment.
        ActiveCell.Comment.Visible = True
        ActiveCell.Comment.Shape.Select
       
        With Selection
           .ShapeRange.AutoShapeType = _       'Set the AutoShape.
               msoShapeExplosion2
       
           .ShapeRange.Fill.PresetGradient _   'Set background color.
               msoGradientHorizontal, 1, _
               msoGradientHorizon
       
           .Font.Name = "Arial"                'Set the font.
           .Font.FontStyle = "Bold Italic"
        End With
       
    End Sub
                        
  2. Select a cell in a worksheet.
  3. Run the Fancy_Comment macro.

    Microsoft Excel inserts a new comment, without the user name, for the active cell.
  4. Click the text area of the comment, and then type the text of the comment.

Displaying the Comment When the Pointer is Over the Cell

After you run either of the macros in this article, the comment remains visible. You can display the comment only when you move the pointer over the red triangle in the top-right corner of the cell with the comment. To do this, use the following steps:

  1. Right-click the cell with the comment.
  2. Click Hide Comment on the shortcut menu that appears.


REFERENCES

For more information about cell comments, click the Index tab in Microsoft Excel Help, type the following text

   comments, overview
                

and then double-click the selected text to go to the "About adding comments and highlighting changes in a workbook" topic.


Additional query words: 97 XL97

Keywords: kbdtacode kbprogramming kbualink97 KB160956