Microsoft Knowledge Base Email Alertz

In Microsoft Excel 2000, the

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 213701 - Last Review: November 23, 2006 - Revision: 3.5

XL2000: Using NoteText and Comment.Text to Apply Comments

This article was previously published under Q213701

On This Page

SUMMARY

In Microsoft Excel 2000, the NoteText method of a cell is limited to a maximum length of 255 characters. This article explains how to work around this limitation and some of the related problems that you may encounter when you work with cell comments.

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 Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners - https://partner.microsoft.com/global/30000104 (https://partner.microsoft.com/global/30000104)

Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice (http://support.microsoft.com/gp/advisoryservice)

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS (http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms)

Working Around the 255-Character Limitation of the NoteText Method

Although the NoteText method of a cell is limited to a maximum of 255 characters, you can apply a comment that is up to 32,767 characters in length to a cell. To do this, use the Text method of a Comment object that is attached to the cell. For example, instead of the following code
ActiveCell.NoteText "This is a 1000 character comment."
				
use a line of code similar to the following:
ActiveCell.Comment.Text "This is a 1000 character comment."
				

Using the NoteText Method with Comments Longer Than 255 Characters

If you use the NoteText method to apply a comment that is longer than 255 characters in length to a cell, the new comment is not applied to the cell, and you do not receive an error message.

For example, if you run a macro with the following code
ActiveCell.NoteText String(256, "x")
				
and the active cell does not already contain a comment, no comment is added to the cell because the length of the new comment would exceed 255 characters.

If you run a macro with the following code
ActiveCell.NoteText ActiveCell.NoteText & String(100, "x")
				
and the length of the existing comment exceeds 155 characters, the comment is not updated because the length of the new comment would exceed 255 characters.

NOTE: In versions of Microsoft Excel before Microsoft Excel 97, the first 255 characters of text are applied to the comment; the remaining characters are truncated.

Using Comment.Text to Change the Comment Applied to a Cell

When you use Comment.Text to change the comment applied to a cell, the cell must already have a comment applied to it. If no comment was previously applied to the cell, you receive the following error message:
Run-time error '91':
Object variable or With block variable not set.
To apply a comment to a cell, use code similar to the following:
ActiveCell.AddComment
				
NOTE: If the active cell already has a comment applied to it, you receive the following error message when you run the code:
Run-time error '1004':
Application-defined or object-defined error.
To add a comment to a cell that may or may not contain a comment, use code similar to the following:
Sub AddACommentToTheActiveCell()

    ' The following line suppresses the run-time error message when
    ' adding a comment to a cell.
    On Error Resume Next

    ' Add a comment to the cell. If the cell already contains a comment,
    ' this line does nothing.
    ActiveCell.AddComment

    ' Return to normal error handling.
    On Error GoTo 0

    ' Add the text to the comment. If the cell already contains a
    ' comment, this is all you actually need.
    ActiveCell.Comment.Text "This is a comment."

End Sub
				

Using Comment.Text to Add New Text to an Existing Comment

If you want to add new text to an existing comment while preserving the original comment text, use a line of code similar to the following:
ActiveCell.Comment.Text ActiveCell.Comment.Text & "New Comment Text"
				
Characters over the 32,767 character limit for comments are truncated.

REFERENCES

For additional information about using comments, click the article number below to view the article in the Microsoft Knowledge Base:
213766  (http://kbalertz.com/Feedback.aspx?kbNumber=213766/EN-US/ ) XL2000: Sample Macro to Remove User Name from Comment
259292  (http://kbalertz.com/Feedback.aspx?kbNumber=259292/EN-US/ ) XL2000: How to Determine If the Active Cell Contains a Comment
213244  (http://kbalertz.com/Feedback.aspx?kbNumber=213244/EN-US/ ) XL2000: Sounds Not Converted with Cell Notes

APPLIES TO
  • Microsoft Excel 2000 Standard Edition
Keywords: 
kbdtacode kberrmsg kbhowto KB213701
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

hotel buchen t�rkei - http://hoteltuerkei.net Report As Irrelevant  
Written: 2/19/2010 6:46 AM
Handle Trust,class die search talk planning himself fall address speed village get past sense grey by listen track slow flat circle aid front publication safe income sure appoint emerge quality maintain cost farmer round settlement software before less correct state question possible available any merely adopt move as factor afraid travel although professional key reaction speech next volume conversation above requirement settle desire comparison pound prepare ahead number defendant northern following failure think new economy something offence environment instead group position promote rise hand expert tomorrow generally occasion little