Macro for special Insert comment text
You wrote:
If you reset the InsertComment to default the Comment will stay open when
you
use Insert Comment from the right-click menu.
You mean reset the menu button? - and shall I still use all of the 3 macros?
I have now reset the worksheet menu bar as descibed he "ExcelTips
Resetting Toolbars to Their Default.mht" and now I get the default Insert
comment text, so this works. This is all right because I only need the right
click possibility.
I have the following macros in my workbook:
ThisWorkbook: The two macro's from you (with danish text for "Insert")
Module1: The new macro with SendKeys (not modified by me)
Result:
The same dialogue box asking me to make a choise still appears and the
Comment box is not open after clicking Accept.
Moreover, I have no longer the possibility to choose Edit comment when I
right click the cell with the just inserted username and date.
Unless you can see something I have done wrong, I think we can't get this
case any closer and I have to give up the project.
Regards,
K. Pedersen
"Gord Dibben" <gorddibbATshawDOTca skrev i en meddelelse
...
The sendkeys line is same as Alt + i + e
Which by default is InsertEdit Comment
Since you have re-programmed the InsertComment on the worksheet menu bar
the
sendkeys will no longer give you the Edit Comment mode but some other
shortcut
function.
On my Excel 2003 the sendkeys inserts and activates a new worksheet.
If you reset the InsertComment to default the Comment will stay open when
you
use Insert Comment from the right-click menu.
It seems you just can't have everything<g
Gord
On Sun, 13 Jan 2008 19:58:44 +0100, "KP" wrote:
Hi,
Thanks for the revised code.
I have replaced the old code with the new one, but I did not succeed in
getting what I wanted.
Now when I right click "Insert comment" an Insert dialogue box appers
asking
me to check if I want to move cells down or cells to the right. Moreover I
can choose one row or one column.
When I have checked one of the possibilities and click the OK button the
username and date is added but the comment box is not kept open.
Do you think this has something to do with my danishversion or do you have
other hints?
Regards,
K. Pedersen
"Gord Dibben" <gorddibbATshawDOTca skrev i en meddelelse
. ..
Glad to hear the run-time has gone away. I never would have guessed
that
you
were using a Danish version.
1. Here is revised code to keep the Comment open and ready to type.
Debra's original code included the sendkeys but I left it out for some
strange
reason. Also dropped the linefeed that produced a blank row below the
date/time.
Sub CommentDateTimeAdd()
'adds comment with date and time and username
Dim strDate As String
Dim cmt As Comment
strDate = "dd-mmm-yy hh:mm:ss"
Set cmt = ActiveCell.Comment
If cmt Is Nothing Then
Set cmt = ActiveCell.AddComment
cmt.Text Text:=Application.UserName & Chr(10) _
& Format(Now, strDate)
Else
cmt.Text Text:=cmt.Text & Chr(10) _
& Format(Now, strDate)
End If
With cmt.Shape.TextFrame
.Characters.Font.Bold = False
End With
SendKeys "%ie~"
End Sub
For question 2, without locking the cell I don't know of a way to
prevent
editing.
With cell locked you could not then delete the Comment.
Gord
On Sun, 13 Jan 2008 15:51:43 +0100, "KP" wrote:
Hi,
I am happy to report that I have now solved the problem and I apoligize
for the inconvenience caused.
In the macro text I just had to change "Insert Comment" to the name of
the
function in the danish version.
Quite simple and I should have been aware of that in the first place.
Now I want to make a change to the macro and I am asking for further
help.
The change I want is as follows:
1.
When I right click "Insert comment" I want the comment box NOT to
disappear until I click another cell.
I want the comment box open, ready to type in with the cursor active.
2.
Is it possible to protect the automatically inserted username and date
so
that it cannot be deleted by editing with backspace or Delete on
keyboard.
The possibility to delete by right click "Delete comment" is all right.
Regards
K. Pedersen
|