Brief guide on automating Word

As there are no dedicated Actions for Word, I decided to have a try with other Robin tools.

The code presumes the existence of a file, ‘C:\temp\HelloRobin.docx’, and Word from Office 2016 in the default location. Modify your file paths accordingly.

The file here, before the robot gets its hands on it, contains:

Here is the code, for demonstration purposes only, as there are better ways to accomplish the end result here.

Notice that we use “{End}{Enter}And that’s a fact” to go to the end of the existing sentence, hit “Enter” to create a new paragraph in Word, and add more text.

Here is the result after our robot modifies the file:


The AppMask is shown below.


To create it, we first grab the screen that appears when opening Word, ‘WordDoc’ (note - you might have to change your settings to open Word with a blank document to achieve this).

Then we add a control ‘FileButton’, for the ‘File’ menu at the top left of the ribbon.

Add a screen for the ‘File’ Screen (here, ‘FileScreen’), and a control for the ‘Browse’ button.

Clicking ‘BrowseButton’ in our code opens the ‘File Open’ dialog (screen ‘FileOpenDialog’). We will populate ‘EditFileName’, a control added to screen ‘FileOpenDialog’, in our code (see above).

Finally, we add another control, ‘OpenButton’, which our code clicks to open the file.

All comments and suggestions welcome! Please note that so far I haven’t used any modifier keys (Ctrl, Alt, Shift, Win) – when and if I’m successful, I’ll post again showing how to use the Clipboard to paste, which should be far faster than SendKeys for longer text passages.


1 Like

Very nice and useful guide @burque505!

Best regards,

James Papadimitriou
Technical Evangelist

1 Like