Discussion
PEGA
Pegasystems Inc.
US
PEGA
Posted: Jun 28, 2021
Last activity: Dec 10, 2021
Last activity: 10 Dec 2021 16:03 EST
RPA Microsoft Word Automation -- How To Save As Another Document Type (PDF)
The MicrosoftWord connector allows you to save a document with a different name. How do you change the document type to PDF for instance? Here is a sample automation that you can import into your projects to perform that task. To call this automation your input parameters include:
- a reference to your MicrosoftWord connector
- the full path to the new file
- a boolean that specifies whether the file should be replaced if already present
- a Microsoft.Office.Interop.Word.WdSaveFormat value which specifies the document type
A couple of items for your attention:
- The WordConnector WordDocument property gives you access to all of the properties, methods and events of your document. Extract a proxy from that property and explore the wealth of options available.
- Many of the methods available in Word have a number of parameters that you may not need or want to provide. The MicrosoftExcel connector has a property called Missing which can be used to supply these parameters (we will add this to the MicrosoftWord connector soon).
- Many methods require special types of input but you cannot select the input directly on the block. Notice how we use an input parameter to select from a Word enum value and then use it in the method.
- To learn what enum value to use, refer to Microsoft's documentation found here- https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.word?view=word-pia. Find the name of the enum and then using the Browse option when adding a parameter navigate to Microsoft.Office.Interop.Word to find the enum by name.
Hope this help you get started doing complex automations in Microsoft Word.
Calling automation:
Word_SaveAs automation: