Enable (don't toggle) Track Changes on MS Word documents

Hi forum. Can anyone suggest a best practice to ensure Track Changes is enabled in MS Word documents? I am aware it can be toggled on/off, but I need to ensure it’s on before changes are made to the document so I know the flow will output word docs with tracked changes. So how do I test whether it’s on or off when the flow begins?

Hello,

So … we do not have an express capability built into our word activities package that would cover this scenario, but since we knew that we can not cover everything we enabled UiAutomation actions inside the word app scope :slight_smile: So my suggestion would be to use UiA to interact with Word and make the necessary actions

Regards,
Dragos.
Ps: here’s a quick example
NewBlankTask271.zip (335.3 KB)

Hi @dragos.suma.
That’s what I am doing so far but I can only find a way to toggle and not enable Track Changes. Hence my bot will only deliver if the input documents do not already have Tracked Changes enabled as it would otherwise disable it when I apply the toggle. I am looking for a way to check if TC is enabled or ensure I can enable TC.

I understand :slight_smile: it kinda dependes on your office version , for me O365 when I open a document which has Track changes enabled there is this “Reviewing” button highlighted


And when it’s disabled it changes to Editing

So with this in mind I updated the example
NewBlankTask271.zip (363.7 KB)

Regards,
Dragos.

Thanks again @dragos.suma.
Good idea. Our company is all for Google products so we’re barely clinging on to our outdated MS product and stuck with older versions like 2016. I played around with Check App State to see how the selector would be specific enough to set the two states apart. Unfortunately the only things that works is to set the selector targeting method to “Image” alone. I don’t know if this is bullet proof enough for a reliable workflow. Any comments on this or any other ideas on how the selector can be adjusted to see if the Track Changes button is on or off?

Well one can use _Document.TrackRevisions Property (Microsoft.Office.Interop.Word) | Microsoft Learn

But in order to do this one has to get his hands dirty and use some code :slight_smile:

Big disclaimer code below is based on internal classes and implementation property of UiPath and are subject to change without notice :slight_smile:

So the big piece of code that needs to be executed is :
Argument2=((Microsoft.Office.Interop.Word.Document)typeof(WordDocument).GetProperty("Document", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(Argument1)).TrackRevisions;

Where Argument1 is the WordDocumentScope handle and Argument2 is the output of the invoke code activity which translates into a variable.

I have updated the example :slight_smile:
NewBlankTask271.zip (365.7 KB)

Thank you @marius.cuciureanu

Regards,
Dragos.

1 Like

Holy Wowzer Wednesday! It works.
Luckily this one is not too frightened by code so one also managed to shoehorn it into one’s StudioX flow :wink: Added the workflow for StudioX here. That’s a keeper for sure. Also VERY happy to hereby learn that In/Out arguments can be used with StudioX. I had no clue and it opens up new and exciting pastures.

Thumbs-up
Word_EnableTrackChanges.zip (325.0 KB)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.