Solved

VB.net Excel problem reading the comments in  cells

Posted on 2014-03-12
4
416 Views
Last Modified: 2014-03-13
Hi

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
MsgBox(S)
Image1.jpg
0
Comment
Question by:murbro
  • 2
4 Comments
 
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

try
Dim S As String = Globals.ThisAddIn.Application.ActiveCell.Comment.Text
MsgBox(S)
0
 
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)
0
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 200 total points
ID: 39925681
Hi,

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

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

Open in new window

Regards
0
 

Author Closing Comment

by:murbro
ID: 39925710
Thank you both
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
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…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now