Word Hacks [Electronic resources]

Andrew Savikas

نسخه متنی -صفحه : 162/ 63
نمايش فراداده

Hack 38 Turn Comments into Regular Text

This hack shows you how to replace a comment''s reference with its text and author.

Comments let reviewers annotate the text without interfering with the text. But if you later import the document into another program, such as Quark or FrameMaker, those comments can cause trouble. Also, when you save a file as a plain-text (.txt) file, you lose any comment references, and the comments end up tacked on at the end, out of context.

In many cases, you can just delete all the comments [Hack #36], but if those comments contain important instructions for a compositor, or other useful information, you may prefer to incorporate the comments into the text and set them off with a bit of markup. A macro can quickly convert those comments into regular text, while retaining their positions in the document.

Select ToolsOptions and click the User Information tab to view the author name assigned to comments you create.

4.13.1 The Code

This macro replaces each comment reference in a document with the text of the comment itself and adds the name of the comment''s author at the end. The entire entry is surrounded in brackets and styled with the built-in Emphasis character style, as shown in Figure 4-20.

Figure 4-20. A Word comment converted to text

Place this macro in the template of your choice [Hack #50] and either run it from the ToolsMacroMacros dialog or put a button for it on a menu or toolbar [Hack #1]. Be sure your cursor is currently in the main text of the document when you run this macro.

Sub ConvertCommentsToInlineText( )
Dim c As Comment
Dim i As Integer
For i = ActiveDocument.Comments.Count To 1 Step -1
Set c = ActiveDocument.Comments(i)
c.Reference.Style = wdStyleEmphasis
c.Reference.Text = " [" & c.Range.Text & " -- " & c.Author & "] "
Next i
End Sub

Though the code never explicitly deletes the comments, Word removes them when the macro replaces their references with text.

4.13.2 Hacking the Hack

Rather than retaining the comments within the text, you can create a separate document containing just the comments.

The following macro creates a table listing each comment in a document, along with the comment''s author. The table is created in a new, blank document.

Sub CreateTableOfComments
Dim c As Comment
Dim i As Integer
Dim docForComments As Document
Dim docActive As Document
Set docActive = ActiveDocument
Set docForComments = Documents.Add
docForComments.Range.InsertAfter _
"Comment" & vbTab & "Author" & vbCr
For Each c In docActive.Comments
docForComments.Range.InsertAfter _
c.Author & vbTab & c.Range.text & vbCr
Next c
docForComments.Range.ConvertToTable _
Separator:=vbTab, _
Format:=wdTableFormatList1
End Sub

4.13.3 See Also

[Hack #95]