Comment

  • Thread starter Thread starter Jack
  • Start date Start date
J

Jack

Hi...

I'm trying to create a macro button that will insert
and/or delete a comment within the active cell without any
access to the menu toolbars.

Also, how can i disable the right click in a workbook?

Thanks if anyone can help me.

Jack
 
Hi Jack,

For comments :

Sub AddOrDeleteComment()
Dim cmt As Comment

If ActiveCell.Comment Is Nothing Then
ActiveCell.AddComment "This is a new comment"
Else
ActiveCell.Comment.Delete
End If

End Sub

For disabling right-click :
Application.CommandBars("Cell").Enabled = False

Amit
 
You are right, it's not needed. I was trying code in a different way before
posting and it simply got left there !!

Amit
 
Amit said:
For comments :

Sub AddOrDeleteComment()
Dim cmt As Comment

If ActiveCell.Comment Is Nothing Then
ActiveCell.AddComment "This is a new comment"
Else
ActiveCell.Comment.Delete
End If

End Sub
Hi, do you need the "Dim cmt as Comment"? Because I can't see where it's
used.

As for the Right Click, you can set Cancel to True in the
BeforeRightClickEvent of the Workbook.

Regards,
 
Hi...

Thanks for your help. I noticed that the code you wrote
puts a comment into the active cell but doesn't allow it
to be edited. What would be good is for a comment box to
be pop up awaiting input.

Thanks in advance...

Gordon...
 
Hi Debra. I checked out your code for comments and am wondering what 'SendKeys "%ie~" does?

Robbyn
 
Used with the SendKeys statement, % represents the Alt key, and ~
represents the Enter key.

When a cell that contains a comment is selected, it's like pressing
Alt+I (to open the Insert menu), then E (to highlight Edit Comment),
then pressing the Enter key to activate the command.
 
Sendkeys "types" those characters

Select a cell with a comment in it.
hit alt-i (insert from the worksheet menubar)
(alt is represented by %)
e (accellerator key for Edit Comment (notice the underline)
~ (sends an enter key)
 
Back
Top