Solved

VB.net Excel problem reading the comments in  cells

Posted on 2014-03-12
4
424 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 49

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

776 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