Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


VB.net Excel problem reading the comments in  cells

Posted on 2014-03-12
Medium Priority
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:Murray Brown
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 1200 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 53

Accepted Solution

Rgonzo1971 earned 800 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

by:Murray Brown
ID: 39925710
Thank you both

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

636 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