Microsoft Word connector methods
Summarize
Summary of Microsoft Word Connector Methods
The Microsoft Word connector methods facilitate automation of various tasks within Microsoft Word documents, enabling more efficient document management and processing. This set of methods allows you to open, modify, and save Word files, among other operations.
Show less
Key Features
- Open: Opens a Word document from a specified local filepath, which is required before using other methods.
- AddFooter: Adds a footer to the document; requires the document to be opened first.
- AddHeader: Inserts a header into the document after opening it.
- ExportToPDF: Converts the Word document to a PDF format, needing the document to be opened initially.
- CellCopy and CellPaste: Copy and paste functionalities for table cell content, requiring the SetTable method to be executed beforehand.
- DeletePage, DeleteRow, and DeleteColumn: Remove specified elements from the document, requiring the Open or SetTable methods as a prerequisite.
- GetTable: Retrieves data from a specified table in the document, allowing for further data manipulation.
- InsertText: Inserts text at the beginning of the document.
- Save and SaveAs: Save changes to the document or save it under a new name.
Key Outcomes
By utilizing these methods, ServiceNow customers can automate and streamline their document processing tasks in Microsoft Word, resulting in increased productivity and accuracy. Customers can expect to effectively manage document content, structure, and format through a series of well-defined operations, ultimately enhancing their workflow efficiency.
The Microsoft Word connector methods enable you to perform various day-to-day tasks with Microsoft Word documents and automate them. For example, add a page footer.
Open
| Parameter | Description | Data port type | Data type | Default value | Mandatory? |
|---|---|---|---|---|---|
| Filepath | Specifies the path to the Microsoft Word file in the local disk. | Data in | String | No default value | Yes |
| Timeout | Specifies the time after which the operation times out. | Data in | Integer | No default value | No |
| Password | Use a password if the document is password protected. | Data in | String | None | No |
| Return | Returns the boolean value based on the outcome of the operation. If True, the file is opened. Else, if False, the file failed to open. | Data out | Boolean | Not applicable | Not applicable |
For details on the issues related to the Open method, see KB article KB1123558 and KB article KB1123548.
AddFooter
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Text | Specifies the text in the footer. | Data in | String | No default value | Yes | |
| FontSize | Specifies the font size of the footer. | Data in | Integer | No default value | Yes |
To provide inputs, see Configure port properties
AddHeader
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Text | Specifies the text in the header. | Data in | String | No default value | Yes | |
| FontSize | Specifies the font size of the header. | Data in | Integer | No default value | Yes |
CellCopy
- Input
- RowIndex, ColumnIndex
CellPaste
- Input
- RowIndex, ColumnIndex
Close
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| saveChanges | Specifies the Boolean value to save or close the document without saving the changes. If True, the changes are saved. Else, if False, the changes are not saved. | Data in | Boolean | No default value | Yes |
DeleteColumn
- Input
- ColumnIndex
DeletePage
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| PageIndex | Specifies the index number of the page that the method deletes. | Data in | Integer | No default value | No | If you don't provide any index number, the method deletes the first page by default. |
DeleteRow
- Input
- RowIndex
DeleteTable
Deletes a table from a Microsoft Word document.
If the document has multiple tables, the method deletes the first table in the document.
ExportToPDF
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Filepath | Specifies the path to the location where the Word document is exported to PDF. | Data in | String | No default value | Yes |
Find
- Input
- Text
- Output
- Return (Boolean)
GetCellValueByIndex
- Input
- CellIndex
GetFooterText
Returns the content of the footer in a Microsoft Word document.
- Output
- Return (String)
GetHeaderText
Returns the content of the header in a Microsoft Word document.
- Output
- Return (String)
GetPageCount
Returns the number of pages in a Microsoft Word document.
- Output
- Return (Integer)
GetRowIndexByValue
GetTable
Returns the data in a table of a Microsoft Word document as a table object and data table. If the document contains multiple tables, you can specify the table index to identify the table for the method. You can also specify the table type, if needed.
- Click the method settings icon (
).
- Select the table type.
- Click OK.
- Input
- TableIndex, FirstRowIsHeader
- Output
- Table (Object)
GetTableCellValues
Returns the values in one or more table cells.
- Click the method settings icon (
).
- Click (
).
- Enter the index values for the cells.
- Repeat the steps to add more index values.
- Click OK.
- Output
- Cell Index (Object)
GetTableCount
Returns the number of tables in a Microsoft Word document. You can optionally specify the type of table for the method to identify.
- Click the method settings icon (
).
- Select the table type.
- Click OK.
- Output
- Return (Integer)
GetTableRowData
Returns the values in one or more cells of a row in a Microsoft Word document. You can specify the index values of the cells of the row.
- Click the method settings icon (
).
- Click the add index value icon (
).
- Enter the index value of the cell.
- Repeat the steps to add more index values.
- Click OK.
- Output
- Row index (Object)
GetText
Returns all the text content in a Microsoft Word document.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| Return | Returns the text from the Word document. | Data Out | String | No default value | Not applicable |
InsertNewColumn
- Input
- ColumnIndex
InsertNewRow
- Input
- RowIndex
InsertPicture
- Input
- ImageFilePath
InsertTable
Inserts a table into a Microsoft Word document. Inserts a table into a Microsoft document. You can optionally customize the document by configuring it before inserting.
- Click the method settings icon(
).
- Select Include Headers.
- Select border style and autofit behavior.
- Select Include Empty Rows.
- To ignore specific columns, click the add index value icon (
).
- Enter the index value of the column.
- Click OK.
- Input
- Bookmark
InsertText
Inserts text in the beginning of the Word document.
| Parameter | Description | Data port type | Data type | Default value | Mandatory? | Notes |
|---|---|---|---|---|---|---|
| text | Takes the text. | Data In | String | No default value | Yes |
IsOpen
Checks whether a Microsoft Word document is open.
- Output
- Return (Boolean)
MergeByCellIndices
- Input
- StartCellIndex EndCellIndex
MergeByRowCol
ReplaceBookmark
- Input
- Bookmark ReplaceText
ReplaceBookmarks
- Input
- Text
- Double-click the component.
- In the PROVIDE LABELS/BOOKMARKS dialog box, click the click to add label icon (
) and enter the bookmark to replace it.
Repeat this step to add more bookmarks.
- Click OK.
ReplaceFooterText
- Input
- FindText
ReplaceHeaderText
- Input
- FindText
ReplaceStaticText
Finds and replaces the text in a Microsoft Word document with the specified text. Replaces bookmarks, headings, or any text based on the configuration.
- Click the method settings icon (
).
- Click the add text icon (
)
- Enter the heading, bookmark, or text that you want to replace.
- Repeat the steps to enter more text.
- Click OK.
- Input
- Object
ReplaceText
- Input
- FindText
Resize
- Input
- Left
Save
Saves the opened Microsoft Word document.
SaveAs
- Input
- Filepath
SetTable
- Input
- Table
SetTableCellValues
Sets the content of a table cell in a Microsoft Word document.
- Double-click the component.
- In the PROVIDE CELL INDEXES dialog box, click the click to add cell index icon (
) and enter a cell index and select a value type.
Repeat this step to add more cell indexes and value types.
- Click OK.
SetTableRowData
- Input
- RowIndex
Provide the column index as follows:
- Double-click the component.
- In the PROVIDE COLUMN INDEXES dialog box, click the click to add cell index
icon (
) and enter a column index.
- Click OK.