Reputation: 27
I know how to add a comment using VBA, but when I use my code selection.Range.comments.Add Range:=selection.Range, Text:=""
to create a comment, then the selected range is in the main text body.
However, If I use the end-user "Add new comment" menu command built into MS Word, after creating the comment the selection is in comment part, so that I can start typing.
How can I do the same with my code: after creating a comment, the selection is in comment part / "box"?
Upvotes: 1
Views: 104
Reputation: 25663
The following demonstrates how you can leave the insertion point (cursor) in the Comment "box" after inserting a comment. Just use the Edit
method of the Comment
object.
Sub SelectionInCommentBox()
Dim rng As Word.Range
Dim cmt As Word.Comment
Set rng = Selection.Range
Set cmt = rng.Comments.Add(rng, "")
cmt.Edit
End Sub
Upvotes: 0