Solved Excel problem reading the comments in  cells

Posted on 2014-03-12
Last Modified: 2014-03-13

I am trying to use the following code to read the comment in an Excel cell
but get the error shown in the image

Dim S As String = Globals.ThisAddIn.Application.ActiveCell.Comment
Question by:murbro
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 300 total points
ID: 39925673
I tried this

Dim S As String
S = ActiveCell.Comment.Text
MsgBox (S)

working fine

Dim S As String = Globals.ThisAddIn.Application.ActiveCell.Comment.Text
LVL 39

Expert Comment

by:Pratima Pharande
ID: 39925677
if comment text empty then also it is throwing error

then I tried this working fine

Dim S As String
 On Error Resume Next

S = ActiveCell.Comment.Text
MsgBox (S)
LVL 51

Accepted Solution

Rgonzo1971 earned 200 total points
ID: 39925681

First you have to test whether there is a comment and then read it

If ActiveCell.Comment Is Nothing Then
MsgBox ("empty")
MsgBox (ActiveCell.Comment.Text)
End If

Open in new window


Author Closing Comment

ID: 39925710
Thank you both

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question