?
Solved

VB.net Excel problem reading the comments in  cells

Posted on 2014-03-12
4
Medium Priority
?
454 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:Murray Brown
[X]
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
4 Comments
 
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

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 52

Accepted Solution

by:
Rgonzo1971 earned 800 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:Murray Brown
ID: 39925710
Thank you both
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

764 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