Is it possible to write an AS that will scan a Microsoft Word file (edited by several editors), collect all the track changes information and corresponding metadata (i.e., who made the change and when) into a separate file (e.g., a CSV file)?
I’m just trying to put all this information into one place, rather than having to scroll through a very long document.
Thanks for the help.
Many thanks for your suggestion. My script, however, only works on short documents (notice, I’m just printing output to screen). On longer documents it times out. I’ve set the timeout for 10 minutes, but the timeout error occurs significantly before 10 minutes (error “Microsoft Word got an error: AppleEvent timed out.” number -1712). Once that happens, MS Word is frozen and needs to be restarted. I’m not sure what’s going on. Here’s my script:
tell application "Microsoft Word"
activate
set myLog to ""
with timeout of (10 * 60) seconds
set myRevisions to every revision of first document
repeat with thisRevision in myRevisions
set thisAuthor to author of thisRevision
if thisAuthor is "Smiling Bob" then
set thisDate to date value of thisRevision
set myLog to myLog & thisAuthor & ", " & thisDate & "
"
end if
end repeat
end timeout
myLog
end tell
I’m not sure I can offer more help; I have Word (2004), but never scripted it.
Anyways, one thing to try is to figure out which part of script is waiting too long. I’d comment out the repeat block, and see if the timeout still occurs.
Another thing to try is different wording, like revisions instead of every revision. I believe I’ve seen apps where this mattered.
Otherwise the only solution I can think of is to work on parts of the document. Word does not have a ‘page’ class, but it has ‘sections’. Can’t help there, sorry.
There’s a 500±page Word 2004 A/S reference here. It says to address revisions by index, not by referencing:
I really appreciate your help! Thank you. I finally got it to work. Your suggestion of breaking down into smaller chunks was the solution (I broke it down by paragraphs). For the sake of completeness, here’s the final code:
tell application "Microsoft Word"
activate
set myLog to ""
set myParagraphCount to count of paragraphs of active document
repeat with i from 1 to myParagraphCount
set thisParagraph to text object of paragraph i of active document
set myRevisions to the revisions of thisParagraph
set revisionCount to the count of myRevisions
if revisionCount > 0 then
repeat with thisRevision in myRevisions
set thisAuthor to author of thisRevision
if thisAuthor is equal to "Smiling Bob" then
set thisDate to date value of thisRevision
set myLog to myLog & thisAuthor & ", " & thisDate & "
"
end if
end repeat
end if
end repeat
beep
myLog
end tell
Good to hear!
And thanks for sharing the working script.