![]() |
#1
|
|||
|
|||
![]()
Hi folks, I seeking a fresh set of eyes to this one.
I scripted together a Sub to loop through the Track Changes in a word doc, if the track change is either Formatting or changes to Field Code values. In theory this Sub worked and I trialled on a small document with success. However, in actual application within the team environment its become hit and miss.. The majority of Changes in these docs are Formatting or Field Codes, and often the important changes can be lost in the sea of unimportant ones. Code:
Public Sub Test_Document_AcceptAll() '' Dim RevisionTotal, RevisionAccepted As Integer '' RevisionTotal = 0 '' RevisionAccepted = 0 Select Case ThisDocument.NewBool Case True ActiveDocument.Revisions.AcceptAll Case Else On Error GoTo RevErr For Each NewRevision In ActiveDocument.Revisions '' MsgBox "Revision Index: [" & NewRevision.Index & "]" & vbNewLine & "Revision Type: " & NewRevision.FormatDescription & "" '' RevisionTotal = RevisionTotal + 1 If Left(NewRevision.FormatDescription, 10) = "Formatted:" Then NewRevision.Accept '' RevisionAccepted = RevisionAccepted + 1 ElseIf Left(NewRevision.FormatDescription, 15) = "Formatted Table" Then NewRevision.Accept '' RevisionAccepted = RevisionAccepted + 1 ElseIf Left(NewRevision.FormatDescription, 11) = "Field Code:" Then NewRevision.Accept '' RevisionAccepted = RevisionAccepted + 1 Else End If Next NewRevision '' MsgBox "" & RevisionAccepted & ": Revisions of a total " & RevisionTotal & " were Accepted..." End Select RevErr: If Err.Number <> 5852 Then Exit Sub Else Err.Clear End If End Sub Both NewBool and NewRevision as Public and delcare elsewhere. I had an inkling that the error might lie with utilising the .FormatDescription property and hence why there is some de-bugging code in there which I've commented out. What I found was that the majority of the time that messagebox returned "" for the .FormatDescription BUT still accepted the change (in the test document). Ran the Sub against the original template and worked fine; still returned "" and accepted the change. Feeling confident, rolled out the template revision to the team and it reverted back to hit and miss... One thing I did discover through trial and error was that Code:
Left(NewRevision.FormatDescription, 9) = "Formatted" These have to be handled seperately, as I've done in the If/ElseIf A fresh pair of eyes or some helpful insight would be greatly appreciated. Thansk in advance. |
Tags |
accept changes, word vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
blackjack | Excel Programming | 1 | 10-11-2014 06:25 AM |
Insert a text conditionally | deboer | Word | 1 | 05-04-2014 03:35 PM |
![]() |
newton.rogers | Excel | 1 | 03-18-2014 12:57 PM |
![]() |
g4tv4life | Excel | 2 | 03-13-2014 10:58 AM |
![]() |
Steve_D | Excel | 2 | 08-24-2012 09:37 PM |