PDA

View Full Version : Organizing Comments and Tracked Changes in a Table



bw82
02-11-2015, 09:29 AM
Greetings,
My knowledge in developing macros in Word is relatively basic, so as I started to approach this task, I quickly realized that I was in serious need of assistance from a more experienced user. I would very much appreciate the help of anyone who could provide a solution that meets my needs.
The Task:
To develop a macro that will review any Word document, identify all Tracked Changes and Comments contained within, as well other corresponding pieces of information (page #, line, author, etc.), and organize them in a table created in a new Word document.


The Purpose:
This table of organized tracked changes and comments by page number will ultimately be manually copied and pasted into an Excel workbook that will house/organize the Tracked Changes and Comments for many Word documents in one or several workbooks. The purpose of the macro is to eliminate the manual process of entering the feedback data into the workbook. For Word documents containing 10's or 100's of pages of these feedback types, this will save a huge amount of time.


The End Product:
I think the best way to help you understand the macro that I need is by explaining what I envision my end product to be.
As mentioned previously, I'd like the macro to produce a table in a new Word document. This table will contain a line item for each tracked change and comment (feedback) identified in the original Word doc. For each line item in the table, there will be a number of columns that will contain various information pertaining to the feedback item - most of this information will be auto-filled by the macro, and one column is intended to be manually filled at a later point and should remain blank. The reason I'd like this blank column included in the table is for easy copy/paste purposes later in my process.


Attached Resource – Excel Workbook – "macro_proposed_tracking_sheet_columns":
I've attached an Excel workbook containing two sheets, and also a Word doc explaining my envisioned end product in further detail.
The first sheet ("Descript. of Macro Created Tabl") of the Excel workbook shows the different columns I'd like included for each line item in the macro created table. Under each column header is a description indicating whether this cell's information will be filled in by the macro or if it should be left blank. If it is intended that the cell be filled in by the macro, I have further described what information should be returned. Please note that for several columns (H,I,J,and K), the macro should only return information pertaining to that line-item based on whether the feedback is a Tracked Change or a Comment. If the line item is a Tracked Change and the column is specific to Comments (or vice versa), the macro should simply return "N/A".
The second sheet ("Exmple of Table Pasted in Excel") of the attached workbook shows what the macro created table will look like when it is copied/pasted in my Excel sheet later in my process. This has been included only to give you a better idea of the macro's purpose.


Attached Resource – Word Document – "macro_produced_table_examples":
The attached Word doc shows what will be produced by this macro. It contains a table with column headers and a line item for each Tracked Change or Comment identified in the original Word doc the macro will be run on. I'd like for the formatting (font, font size, borders, background color, page orientation, column widths, etc.) to be consistent with this example. The order of the table's contents should align with the order of the feedback left in the document – feedback left on page 1 with be listed above feedback on page 2, and so on.
Below the table, you will see an explanation of each line item. This is only included to help clarify my needs and should not be included in the end product.


Conclusion:
I believe that sums up everything. If you have any questions, please feel free to respond within this post. Thank you.1284512846

gmaxey
02-11-2015, 10:16 AM
bw82,

Something like this should get you started:

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oDoc As Document, oDocRecord As Document
Dim oRow As Row
Dim oTbl As Word.Table
Dim oRev As Revision
Dim oRng As Range
Dim oCom As Comment
Set oDoc = ActiveDocument
Set oDocRecord = Documents.Add
Set oTbl = oDocRecord.Tables.Add(oDocRecord.Range, 2, 5) 'Decide how many colummns
Set oRow = oTbl.Rows.First
With oRow
.Cells(1).Range.Text = "Type"
.Cells(2).Range.Text = "Page"
.Cells(3).Range.Text = "Author"
.Cells(4).Range.Text = "Initial"
.Cells(5).Range.Text = "User Note"
End With
For Each oRev In oDoc.Revisions
Set oRow = oTbl.Rows.Last
With oRow
.Cells(1).Range.Text = "Rev"
.Cells(2).Range.Text = oRev.Range.Information(wdActiveEndPageNumber)
.Cells(3).Range.Text = oRev.Author
End With
oTbl.Rows.Add
Next oRev
For Each oCom In oDoc.Comments
Set oRow = oTbl.Rows.Last
With oRow
.Cells(1).Range.Text = "Comment"
.Cells(2).Range.Text = oCom.Reference.Information(wdActiveEndPageNumber)
.Cells(3).Range.Text = oCom.Author
.Cells(4).Range.Text = oCom.Initial
End With
oTbl.Rows.Add
Next oCom
oTbl.Rows.Last.Delete
End Sub