PDA

View Full Version : Solved: Accept All Changes Shown



rruckus
07-08-2011, 03:05 PM
Has anyone written their own "Accept All Changes Shown" macro? If so, can you share it?

I need to slightly modify this feature, so I figured the only way is to write my own and take over Words ribbon item. I can loop through all the revisions, but how do I know if a given revision is shown or not?


Dim oRevision As Revision
For Each oRevision In ActiveDocument.Revisions
If oRevision.Hidden = False Then
oRevision.Accept
End If
Next oRevision


The problem is that there is no "oRevision.Hidden" property! Is there another collection of shown vs hidden changes that I can go through? Any thoughts?

macropod
07-09-2011, 03:31 AM
Hi rruckus,

Why do you need to know whether a revision is hidden? To accept all revisions all you should need is:
ActiveDocument.Revisions.AcceptAll

Jay Freedman
07-09-2011, 11:01 AM
Hi Paul,

I can understand why rruckus wants to "Accept All Shown" -- if there are tracked changes by multiple authors in the document, you can choose to show only the ones made by one reviewer (or several, but not all, reviewers) and accept just those, leaving the others still marked.

None of the properties of the Revision object give any information about whether the revision is shown, and I haven't seen any property of the revision's Range property that helps, either.

The best I can suggest is to display a userform with a multiselect listbox containing the list of reviewers (that is, duplicate the function of the Review > Show Markup > Reviewers menu), and then have the macro compare each revision's Author property to the selections from the listbox to decide whether to accept the revision.

rruckus
07-11-2011, 08:01 AM
Hi rruckus,

Why do you need to know whether a revision is hidden? To accept all revisions all you should need is:
ActiveDocument.Revisions.AcceptAll

I need to write my own function for "Accept All Changes Shown". So I certainly cannot use ".AcceptAll". It will accept revisions that are hidden - that's not what I want to do. I also can't use "WordBasic.AcceptAllChangesShown" which will only accept the hidden changes because I need to work my own logic into the decisions as to when to accept or not.

I only want to accept revisions shown that meet my own criteria. What that criteria is doesn't really matter. But if you think it will help, I am using lots of content controls in my documents and I don't want users to be able to ever Accept the Deletion of a CC or Reject the Insertion of a CC because it will remove the CC and I don't want that to happen. So my logic looks to see if the tracked change spans a CC and will not allow the accept/reject to happen if it does.

I also can't show a userform or similar - it must work exactly like Words "Accept All Changes Shown feature" except for my little bit of logic.

I'm thinking the answer lies in looking at the properties of the document vs the properties of each single change:

Dim oRevision As Revision
For Each oRevision In ActiveDocument.Revisions

If ActiveWindow.View.Reviewers(oRevision.Author).Visible = True Then 'Don't process TCs by hidden authors

If (oRevision.Type = wdRevisionInsert Or oRevision.Type = wdRevisionDelete) And ActiveDocument.ShowRevisions = False Then
'Don't accept changes that are hidden
Else
'Allow the accept
End If
End If
Next oRevision

macropod
07-12-2011, 12:32 AM
Hi rruckus,

I think you've got some fundamental issues you're going to have to resolve before you'll ever get this to work. For example:
1. You cannot force users to run your macro;
2. You cannot force users to track changes; and
3. If you allow Content Controls to be added by the user, you cannot prevent other Content Controls in the same Section being deleted or relocated.

I am using lots of content controls in my documents and I don't want users to be able to ever Accept the Deletion of a CC or Reject the Insertion of a CC because it will remove the CC and I don't want that to happen.
For the deletion prevention, why don't you simply set the Content Control properties to 'Content Control cannot be deleted'?

rruckus
07-12-2011, 08:13 AM
I knew that explaining the reason WHY I'm doing it would distract you :) I'm handling all cases you mention and more - so just ignore WHY I need to do it. Here's how I am handling your points in case you want to know:

1. Sure you can, take over the Ribbon Items (in my template custom ui xml file) so the users don't even know they are running my macros
2. I don't need to force them to track changes, I want all functionality related to actually tracking of changes to work as is - it's the accepting/rejecting I need to control
3. I have a very controlled application that locks down pretty much everything except my buttons and track changes. It's a very complex specialized application with over a year of development.

Yeah the obvious way is to set the CC property to "Content Control cannot be deleted" but it goes against all of my current CC locking rules (I have my own set of authoring rules that define whether or not my CC can be deleted). Maybe I need to expand those rules to account for TCs.

My pseudo code above actually does work, I just need to make sure it takes all possibilities of whether or not a TC is hidden.

macropod
07-12-2011, 06:06 PM
Hi rruckus,

Re:

Sure you can, take over the Ribbon Items (in my template custom ui xml file) so the users don't even know they are running my macros
Hate to rain on your parade, but that's easily defeated - even unwittingly! If it were possible to enforce the running of macros, virus writers would love it!

I don't need to force them to track changes, I want all functionality related to actually tracking of changes to work as is - it's the accepting/rejecting I need to controlSo, if a user disables 'Track Changes' and deletes a Content Control, you don't care?

Getting back to the original issue, though, since changes can be made visible/invisible by reviewer, perhaps the best approach is to build a dictionary of visible/invisible reviewers, then accept/reject changes on that basis, much as your code in post #4 above suggests.

rruckus
07-12-2011, 07:34 PM
Hi rruckus,

Re:

Hate to rain on your parade, but that's easily defeated - even unwittingly! If it were possible to enforce the running of macros, virus writers would love it!
So, if a user disables 'Track Changes' and deletes a Content Control, you don't care?

Getting back to the original issue, though, since changes can be made visible/invisible by reviewer, perhaps the best approach is to build a dictionary of visible/invisible reviewers, then accept/reject changes on that basis, much as your code in post #4 above suggests.
We certainly don't have to bring deployment issues into this question! It's way off topic and already well taken care of. This is an existing product that works well. People use the *signed* macros willingly and know that if they disable them it won't work.

I already properly manage the CC locks and it works well.

And like I said, my code example from earlier is working now.

Uttam.S
04-29-2016, 11:44 AM
Has anyone written their own "Accept All Changes Shown" macro? If so, can you share it?

I need to slightly modify this feature, so I figured the only way is to write my own and take over Words ribbon item. I can loop through all the revisions, but how do I know if a given revision is shown or not?


Dim oRevision As Revision
For Each oRevision In ActiveDocument.Revisions
If oRevision.Hidden = False Then
oRevision.Accept
End If
Next oRevision


The problem is that there is no "oRevision.Hidden" property! Is there another collection of shown vs hidden changes that I can go through? Any thoughts?

I had slightly different need to accept all formatting changes while keep the rest. The below code is what I used for the same:
ActiveWindow.View.ShowInsertionsAndDeletions = False
ActiveWindow.View.ShowFormatChanges = True
ActiveWindow.View.ShowInkAnnotations = False
ActiveWindow.View.ShowComments = False

ActiveDocument.AcceptAllRevisionsShown

ActiveWindow.View.ShowInsertionsAndDeletions = True
ActiveWindow.View.ShowFormatChanges = True
ActiveWindow.View.ShowInkAnnotations = True
ActiveWindow.View.ShowComments = True


Kind Regards, Uttam