XL: How to use a Macro to Enter Cell Note Text in a Text Box

Last reviewed: February 3, 1998
Article ID: Q142119
The information in this article applies to:
  • Microsoft Excel 98 Macintosh Edition
  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a

SUMMARY

This article describes how to put the text of a text note (cell note) into a text box. A macro that does this may be especially helpful if you are using Microsoft Excel for the Macintosh, because in this version of Microsoft Excel, you do not have the ability to manually copy text from the text note dialog box and paste it into a text box.

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 engineers 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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

The following sample macro creates a text box and fills it with the text from a text note.

Sample Visual Basic Procedure

   Sub GetCellNote()
       Dim Box As Object, X As Integer
       ' Check to see if a Note is in the Active Cell.
       If Len(ActiveCell.NoteText(Start:=X * 255 + 1)) = 0 Then
           MsgBox "There is not a note in the Active Cell.", vbExclamation
           Exit Sub
       End If
       ' Add a text box.
       Set Box = ActiveSheet.TextBoxes.Add(ActiveCell.Offset(1, 1).Left, _
           ActiveCell.Offset(1, 1).Top, ActiveCell.Offset(1, 3).Left, _
           ActiveCell.Offset(6, 1).Top)
       ' We can only get 255 Characters at a time; so, loop until all of
       ' the note is retrieved.
       Do Until Len(ActiveCell.NoteText(Start:=X * 255 + 1)) = 0
           Box.Characters(X * 255 + 1).Text = _
               ActiveCell.NoteText(Start:=X * 255 + 1)
           X = X + 1
       Loop
   End Sub

To use the preceding macro in Microsoft Excel 97 or Microsoft Excel 98, point to Macro on the Tools menu, and then click Macros. (In earlier versions, click the cell that contains the note, and then click Macro on the Tools menu.) Click the GetCellNote macro, and then click run. If necessary, size the text box such that you can view the entire note.


Additional query words: 5.00 7.00 8.00 XL97 XL98 XL7 XL5
Keywords : kbcode kbprg PgmHowto
Version : WINDOWS:5.0,7.0,97; MACINTOSH:5.0,98
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.