Hi Mike,
Actually the code above had a bug but i solved it now.
1- Open a new workbook.
2- Click Tools_Macro_Visual Basic Editor (or Alt+F11) to open VBA. You are in VBA editor now.
3- Click View_Project Explorer (or Ctrl+R) to see Project explorer.
4- You will see VBAProject Object and Microsoft Excel Objects under this item.
5- Double click on Microsoft Excel Objects. You will see 3 sheet object (depends on your new workbook sheet count) and definetely one workbook object named as Thisworkbook.
6- Double click on Thisworkbook object then you will see thisworkbook module window. It will say General and Declarations in little comboboxes at the top of that window.
7- Paste these two codes there:
'This first code set OnAction property for right click menu and main menu Insert Comment function. OnAction property is always empty as default because Excel functions does internal jobs. But we can change them by using OnAction property. Now our two menu items (Comment in Insert menu and Insert Comment in Right click menu on cells) will run the "ChangeCommentAction" function which we will write soon.
Private Sub Workbook_Open()
Application.CommandBars("Insert").Controls("Comment").OnAction = "ChangeCommentAction"
Application.CommandBars("Cell").Controls("Insert Comment").OnAction = "ChangeCommentAction"
End Sub
'This code will set your Comment functions as default. It means when you try to close this workbook then they will stop running that macro and use default actions. This is important, you should do this (until you decide to use this macro and let me tell you how you would put it in your personal workbook to run for all your documents) because if we didnot set the default actions then you will get some errors because you closed the workbook which has macro.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Insert").Controls("Comment").OnAction = ""
Application.CommandBars("Cell").Controls("Insert Comment").OnAction = ""
End Sub
8- Now goto menu and Insert_Module and you will see that you inserted a new module which will keep our main macro. You should see that new code window opened for Module1. Just paste the code below in it.
'This code run by Insert Comment in right click menu or Insert_Comment menu. As you can read in english in code: it Add a Comment into the ActiveCell and then it set its text as null ("", which you want) and then make it visible to select and let you write comments in it.
Private Sub ChangeCommentAction()
ActiveCell.AddComment ""
ActiveSheet.Shapes(ActiveCell.Comment.Shape.Name).Visible = msoCTrue
ActiveSheet.Shapes(ActiveCell.Comment.Shape.Name).Select
End Sub
9- Save your workbook and close it then reopen. Now you can be happy i hope. (Dont worry if you dont see the cursor is not blinking in comment area, just start typing when you see it)
10- If you are having troubles please let me know to send you a sample xls file to see and at least be able to decide to apply or not.
Regards
_________________
Oz ~
TheWordExpert
This message was edited by smozgur on 2002-04-23 14:27