Excel - How to determine if selected shape is a Comment

B

bourgui

Hi guys,

quick question before I find some horrendous, tortuous way of doing
it:
Is there a simple way in Excel VBA to determine whether the selected
shape is a Comment?

Thanks!
 
M

macropod

Hi bourgui,

Here's a fairly simple test, that relies on the fact that Comments are automatically named 'Comment #' by Excel (# = a number). It
is possible, but unlikely that a user would have deleted 'Comment' from the name.

Sub TestForComment()
MsgBox InStr(Selection.Name, "Comment") > 0
End Sub
 
M

macropod

Hi bourgui,

Here's a more reliable method:
Sub TestForComment()
MsgBox Selection.ShapeRange(1).Type = msoComment
End Sub
 
B

bourgui

Hi Guys,

Thanks to you both, I actually found the way explained by macropod 5
minutes after posting (my vba Help wasn't working, so I reinstalled
Office and all was good!)

Bourgui
 
B

bourgui

Lol.

I was running out of the office. I saw the 2 different answers,
blindly assumed they were from different people and typed a rushed
answer.
Did I put down 'Attention to detail' anywhere on my CV? ;o)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top