none
index comments RRS feed

  • Question

  • good afternoon all. 

    I have a macro that I looked up online, and I'd like to modify it a bit. It works fine, I just want to further modify it.

    In my word document I've inserted a LOT of comments. Most of my comments are within their particular comment body, and I'd like to index all of them, including the ones which are multiples within a single comment. 

    Sub exportcomments() Dim s As String Dim cmt As Word.Comment Dim doc As Word.Document For Each cmt In ActiveDocument.Comments

    '///////////////////////////////////////

    ' don't want the numbering, or my initials. 'only want comment text/content only. 's = s & cmt.Initial & cmt.Index & "," & cmt.Range.Text & vbCr '////////////////////////////////////// s = s & cmt.Range.Text & vbCr Next Set doc = Documents.Add doc.Range.Text = s End Sub


    As I'm sure you're familiar, we can insert a comment from the ribbon, or by right-clicking. 

    I've done this, and then, for the purposes I have, I've inserted questions in each. Most of the time I've inserted upwards of 3-6 questions in each comment. 

    I understand that this code below--- reads the entire contents of the comment, and then sets a carriage return. Is there a way to restrict the reading of the comment's contents by a question mark, or other punctuation? It cannot be restricted by the amount of text in the comment, because the questions all differ in length. Each item however is separated by a question mark, and then the carriage return I've done by hitting the enter key.  

    TYIA.

    cmt.Range.Text & vbCr

    Tuesday, June 16, 2020 7:55 PM

All replies

  • It's not apparent to me, at least, what you mean by «restrict the reading of the comment's contents by a question mark». If you want to split the comments into separate paragraphs by question, the simple solution would be to use:

    doc.Range.Text = Replace(s, "?", "?" & vbCr)


    Cheers
    Paul Edstein
    [MS MVP - Word]



    Tuesday, June 16, 2020 11:24 PM