Automation is a game-changer in the world of productivity and efficiency. It’s all about streamlining processes, ensuring consistency, and, believe it or not, even providing a sense of buoyancy. Yes, you read that right – buoyancy. Desktop automation can be your secret weapon in keeping those seemingly irreplaceable legacy systems afloat, even when they’re driving your CIO crazy. After all, many of your colleagues are still in love with those systems because they just work – that’s the magic of automation.
But desktop automation isn’t limited to legacy system support; it can also enhance your everyday tasks, like automating Microsoft Word. Now, you might be thinking, “I can do that with a cloud flow,” and you’re not wrong. Cloud-based automation is fantastic for updating templates and structured data. However, what I’m proposing is taking automation to the next level by working with free text.
But, before we dive into the exciting world of free-text automation, let’s talk safety first. There’s no point in automating something if we can’t roll it back in case of a mishap. We’ve all been there – that heart-pounding moment when you’ve pushed the proverbial ‘red button,’ and suddenly, you’re in a lonely, isolating place where your brain feels like it’s losing blood, and you start wondering if you’ll still have a job in the next five minutes. That’s why it’s crucial to implement safety measures to avoid such nerve-wracking situations.
The Guard Rails
In this exercise, we’ll be focusing on a SharePoint document library, which is already equipped with robust document management features such as check-in/check-out and version history. However, one feature that might be missing from your SharePoint arsenal is the ability to activate ‘Track Changes.’
Desktop automation opens up exciting possibilities, allowing us to activate ‘Track Changes’ effortlessly. One of my personal favorites for achieving this is harnessing the power of PowerShell in combination with desktop flows.
PowerShell provides the ultimate level of control and efficiency, eliminating the need for multiple unnecessary actions by allowing us to solve complex tasks with a single script. It’s a game-changer when it comes to automating tasks and streamlining processes in desktop flows.
The Solution

To work with a document in SharePoint and access its settings, follow these steps:
- Right-click on the document you want to work with within your SharePoint document library.
- From the context menu that appears, select “Copy Link.”
- After copying the link, proceed to select the “Settings” link or option to access and configure the document’s settings as needed. This step may vary slightly depending on your specific SharePoint environment and version.

4. In the sharing settings, you should see an option to invite people or add users. Enter the email addresses of the users you want to grant “Can Edit” permissions to. You can also use SharePoint groups if applicable.
5. Select apply and the link will be copied to your clipboard and settings for sharing saved.

In Power Automate Desktop
- Add the ‘Terminate’ action
- Configure the “Terminate” action settings as follows:
- Process Name: Enter “WINWORD.EXE” (without quotes) in the “Process Name” field. This is the executable name for Microsoft Word.
- Action: Choose “Terminate” to close any running instances of Microsoft Word.
- Save your flow with the “Terminate” action in place.

2. Next we’ll add an action called ‘Run application’

For the “Run application” action with the specified parameters, here’s how you can configure it:
- Application Path: Enter “winword.exe” (without quotes) as the application path. This specifies that you want to run Microsoft Word.
- Command Line Arguments: Enter “/t” followed by the sharing link from the Word document in your document library. Make sure to replace “sharing link” with the actual URL or path to your Word document. For example, if your document’s sharing link is “https://example.com/document.docx,” your command line argument would be “/t https://example.com/document.docx.”
- Window Style: Set the window style to “Maximized.” This will ensure that the Microsoft Word application window is opened in a maximized state.
With these parameters, the “Run application” action will launch Microsoft Word with the specified command line arguments, opening the document in a maximized window.
Sidebar – sort of
Introducing the concept of command line switches is crucial when working with Microsoft Office products and many other applications. Command line switches provide a convenient way to customize how an application behaves when launched from the command line or as part of an automation process.
In our specific case, the “/t” switch used before the document link is a common command line switch for Microsoft Word, indicating that we want to open an existing file. By including this switch in the command line arguments, we instruct Microsoft Word to treat the provided link as the path to an existing document that should be opened.
Back to regularly scheduled programming…
Next, we’ll insert two left clicks to the foreground window, which should be Microsoft Word, you can use the “Mouse Click” action. The goal is to mitigate any potential dialog interruptions:
- Add a “Mouse Click” action to your automation.
- In the “Mouse Click” action settings, specify the following:
- Click Type: Choose “Left Click” to perform a single left-click.
- Target: Select “Foreground Window” to ensure that the click is directed to the currently active window, which should be Microsoft Word.
- Repeat: Set the “Repeat” option to “1” to perform the click once.
- After the first “Mouse Click” action, add another “Mouse Click” action with the same settings as the first one.
Trust me this step is warranted; I’ve seen some weird things in my time.

Now, let’s incorporate a PowerShell script into our workflow to achieve the goal of enabling track changes for our document. What makes this script particularly useful is its precision: it focuses solely on enabling track changes. Importantly, if track changes are already active, the script won’t “bat an eye”. However, if track changes are not yet enabled, the script will take action, enforcing track changes and ensuring that revisions are visible as they occur.
- Add a “Run PowerShell Script” action to your automation.
- In the “Run PowerShell Script” action settings, you can paste the provided script into the script editor. Make sure to include the entire script:

$wordApp = [System.Runtime.Interopservices.Marshal]::GetActiveObject("Word.Application")
# Get the active document
$document = $wordApp.ActiveDocument
# Enable track changes
$document.TrackRevisions = $true
$document.ShowRevisions = $true
# Save changes (optional)
$document.Save()
- Save your flow with the “Run PowerShell Script” action included.
Let’s introduce a step to test our automation by using the ‘Send Keys’ action. In the input parameters, we’ll enter a specific text of our choice. For instance, I’ll input “tested.” This action will transmit this free-text input directly to our Word document, allowing us to verify the effectiveness of our automation process.

Run the flow


































