Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4073540
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:02:14+00:00 2026-05-20T17:02:14+00:00

I have a user form in Word 2007 which searches for specific terms in

  • 0

I have a user form in Word 2007 which searches for specific terms in a document and adds comments. I have three different categories for these comments. I want the comments to be color coded for each category. For the moment I have a solution which works but it is very slow. Is there another way to assign a comment author directly when creating the comments?

Code for comment creation:

For i = 0 To UBound(CritArray)
    PosCount = 1
    With Selection
    .HomeKey wdStory
        With .Find
        .ClearFormatting
            Do While .Execute(FindText:=CritArray(i), _
            Forward:=True, _
            MatchWholeWord:=True)
Select Case i
...
End Select
            PosCount = PosCount + 1

            Selection.Comments.Add _
            Range:=Selection.Range, _
            Text:=MessArray(i) & CritArray(i) & "' - found for the" & Str(FoundCount) & ". time"

            Loop

        End With
    End With
Next

Code for assigning a different author to each comment – this results in different color coded comments if under Review>Track Changes>Track Changes Options>Comments by author is selected:

Dim CurrentExpField As String

For Each objCom In ActiveDocument.Comments

    CurrentExpField = Left$(objCom.Range.Text, 3)
    objCom.Author = UCase(CurrentExpField)
    objCom.Initial = UCase(CurrentExpField)

Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:02:15+00:00Added an answer on May 20, 2026 at 5:02 pm

    Yes, it is possible to set additional properties for a Comment after it is created since the Add method for Comments returns a reference to a new Comment object. This means that you can do your colour-coding in one pass. I modified your code slightly to do this as follows:

    Dim cmtMyComment as Comment
    
    For i = 0 To UBound(CritArray)
        PosCount = 1
        With Selection
        .HomeKey wdStory
            With .Find
            .ClearFormatting
                Do While .Execute(FindText:=CritArray(i), _
                Forward:=True, _
                MatchWholeWord:=True)
    Select Case i
    ...
    End Select
                PosCount = PosCount + 1
    
                Set cmtMyComment = Selection.Comments.Add(Range:=Selection.Range, _
                Text:=MessArray(i) & CritArray(i) & "' - found for the" & Str(FoundCount) & ". time")
    
                cmtMyComment.Author = UCase(Left$(cmtMyComment.Range.Text, 3))
                cmtMyComment.Initial = UCase(Left$(cmtMyComment.Range.Text, 3))
    
                Loop
    
            End With
        End With
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Word document that contains about 4000 form fields which I have
I have a searching form that the user should enter a word. Till now
I have a text-box which allows users to enter a word. The user enters:
I have a form where a user inputs a word, when pressing the button
I have a form into which the user can add more fields to fill
Let's say I have an user registration form. In this form, I have the
I have to display a column chart in a user form in VBA. Exporting
I have a requirement wherein I need to display on a User form, a
I have form with user defined filters ( combobox with column names, combobox with
I have form where user submits field. Field can have letters, numbers, and punctuation.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.