Reactor4
Reactor4

Reputation: 111

Creating varying pre-set comments in a single MS Word VBA script

I am currently using this very simple script to leave comments on MS Word files:

Sub Comment()

ActiveDocument.ActiveWindow.View.ShowHiddenText = True
Selection.Comments.Add Range:=Selection.Range, Text:="Comment Text"

End Sub

I wonder if this script can be upgraded in such a way that it would cycle a set of different comments as I go through the text? I am doing this as I have assigned a comment to almost every keyboard combination as a shortcut --and it is very cumbersome to memorize all those shortcuts.

Upvotes: 0

Views: 40

Answers (1)

macropod
macropod

Reputation: 13490

That could be as simple as:

Sub CommentSelect()
With Selection
  Select Case InputBox("Choose: " & vbCr & _
    "1. Comment 1 Description" & vbCr & _
    "2. Comment 2 Description" & vbCr & _
    "3. Comment 3 Description" & vbCr & _
    "4. Comment 4 Description" & vbCr & _
    "5. Comment 5 Description")
    Case 1: .Comments.Add .Range, "Comment 1 Text"
    Case 2: .Comments.Add .Range, "Comment 2 Text"
    Case 3: .Comments.Add .Range, "Comment 3 Text"
    Case 4: .Comments.Add .Range, "Comment 4 Text"
    Case 5: .Comments.Add .Range, "Comment 5 Text"
  Case Else
End Select
End With
End Sub

Upvotes: 1

Related Questions