Comment Box is left open...need to close!

salmerin

New Member
Joined
May 14, 2007
Messages
27
I have this code that I got from another site, however, this code allows the user to enter a comment without the UserInput window, the only problem is that it leaves the comment window open and it won't close when the user selects another cell.

Code:
Sub CommentAddOrEdit()
'method suggested by Jon Peltier 2006-03-04
'adds new plain text comment or adds text
'at end of existing comment text
  Dim cmt As Comment
  Set cmt = ActiveCell.Comment
  If cmt Is Nothing Then
    Set cmt = ActiveCell.AddComment
    cmt.text text:=""
  End If
  
  'type to add comment text to selected shape
  cmt.Visible = True
  cmt.Shape.Select

End Sub

How do I modify this so that when the user is done with the comment, and the user selects another cell to get the focus out of the comment box, the box will close?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try

Rich (BB code):
cmt.Visible = False

and delete

Rich (BB code):
cmt.Shape.Select
 
Upvote 0
I think that the comment has to be selected. It looks like the code is using that Selection to invoke the normal comment edit box.

One of my thoughts is that the sub is unneeded. I don't see the advantage of pressing a button to invoke that macro over just right clicking on the cell and selecting Edit co
 
Upvote 0
I think that the comment has to be selected. It looks like the code is using that Selection to invoke the normal comment edit box.

One of my thoughts is that the sub is unneeded. I don't see the advantage of pressing a button to invoke that macro over just right clicking on the cell and selecting Edit co

The problem is that the whole workbook is password protected, and in order to run other macros on any given sheet the (ActiveSheet.Protect Password:="Some password here") gets executed in order to make changes. So, the right click part you are talking about does not work as the Add | Edit | Delete Comment options aren't shown.

This is the reason for the Comment Sub I was inquiring about by using the normal edit window but can't get it to work properly as it remains open....and if I select .Visible to False then it won't open to add comments.
 
Upvote 0
I don't know what version you are using, but Excel 2007 or after you can allow the user to "Edit Objects" on a protected sheet (Review tab>Protect sheet is how to get to this control).

Once that is set, the user will not be able to change a cell's contentets, but right clicking on a cell will give them the option to insert or edit comments.
 
Upvote 0
I don't know what version you are using, but Excel 2007 or after you can allow the user to "Edit Objects" on a protected sheet (Review tab>Protect sheet is how to get to this control).

Once that is set, the user will not be able to change a cell's contentets, but right clicking on a cell will give them the option to insert or edit comments.

The sheets (workbook) is password protected using VBA therefore I need a way to allow users to "Edit Objects" using vba.

If I use something similar to this:
Code:
.Protect DrawingObjects:=False, Contents:=True, Scenarios:=True

But instead of "DrawingObjects", could I use something about EditObjects?
 
Upvote 0
The setting that I mentioned can't be edited from VBA (as far as I can see).

But if you make that setting manualy, it will stick with the workbook and allow comment editing when the sheet is protected with VBA.
 
Upvote 0
The setting that I mentioned can't be edited from VBA (as far as I can see).

But if you make that setting manualy, it will stick with the workbook and allow comment editing when the sheet is protected with VBA.

Thanks, I'll give it a go!
Appreciate everyone's help in here!
 
Upvote 0
The setting that I mentioned can't be edited from VBA (as far as I can see).

But if you make that setting manualy, it will stick with the workbook and allow comment editing when the sheet is protected with VBA.

Thanks, I'll give it a go!
Appreciate everyone's help in here!
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top