SAP Help Home SAP Intelligent RPA Help Portal SAP Intelligent RPA Community

Module - Document

Collection of functions related to MS Word documents such as open a document, save a document, save as, save as PDF...

Activities

Open Document (Word)

Open a specified Word document.


Technical Name Type Minimal Agent Version
openDocument synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
documentPath string mandatory Path of the document.

Sample Code:

irpa_word.document.openDocument(documentPath);

Errors:

Error Class Package Description
SequenceError irpa_core The Word Application cannot be null
NotFound irpa_core Document not found


Open New Document (Word)

Open a new blank Word document.


Technical Name Type Minimal Agent Version
newDocument synchronous WIN-2.0.0

Sample Code:

irpa_word.document.newDocument();

Errors:

Error Class Package Description
SequenceError irpa_core The Word Application cannot be null


Change Active Document

Make a specified document the active Word document.


Technical Name Type Minimal Agent Version
changeActiveDocument synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
documentName string mandatory The name of the document to activate.

Sample Code:

irpa_word.document.changeActiveDocument("myDocument.docx");

Errors:

Error Class Package Description
SequenceError irpa_core The Word Application and the current document must be defined


Save As (Word)

Save a new Word document with a specified file name. Save a previously saved Word document under a different name.


Technical Name Type Minimal Agent Version
saveAs synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
filePath string mandatory Path of the file to save as.
fileFormat irpa_word.enums.format optional wdFormatDocumentDefault Use irpa_word.enums.format to choose the proper format.

Sample Code:

irpa_word.document.saveAs(filename, fileFormat);

Errors:

Error Class Package Description
SequenceError irpa_core The Word Application and the current document must be defined


Save As PDF (Word)

Save a specified Word document as PDF.


Technical Name Type Minimal Agent Version
saveAsPdf synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
filePath string mandatory Path of the file to save as.

Sample Code:

irpa_word.document.saveAsPdf(filename);

Errors:

Error Class Package Description
SequenceError irpa_core The Word Application and the current document must be defined


Save (Word)

Save the latest changes of an active Word document.


Technical Name Type Minimal Agent Version
save synchronous WIN-2.0.0

Sample Code:

irpa_word.document.save();

Errors:

Error Class Package Description
SequenceError irpa_core The Word Application and the current document must be defined


Close Document (Word)

Close a specified Word document after saving the latest changes.


Technical Name Type Minimal Agent Version
close synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
hasToBeSaved boolean mandatory True if the Word document has to be saved, false otherwise.

Sample Code:

irpa_word.document.close(hasToBeSaved);

Errors:

Error Class Package Description
SequenceError irpa_core No current document.


Get Bookmark List

Retrieve the list of defined bookmarks in the current Word document.


Technical Name Type Minimal Agent Version
getBookmarkList synchronous WIN-2.0.0

Output Parameters:

Name Type Description
bookmarkList Array. List of bookmarks.

Sample Code:

irpa_word.document.getBookmarkList();

Errors:

Error Class Package Description
SequenceError irpa_core The Word Application and the current document must be defined


Check Bookmark

Checks if a bookmark exists in the current Word document.


Technical Name Type Minimal Agent Version
checkBookmark synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
bookmarkName string mandatory Bookmark name.

Output Parameters:

Name Type Description
exists boolean Bookmark existence.

Sample Code:

irpa_word.document.checkBookmark('myBookmark');

Errors:

Error Class Package Description
SequenceError irpa_core The Word Application and the current document must be defined


Set Bookmark Value

Set a value to a specified bookmark range into the current Word document.


Technical Name Type Minimal Agent Version
setBookmarkValue synchronous WIN-2.0.0

Input Parameters:

Name Type Attributes Default Description
bookmarkName string mandatory Bookmark name.
bookmarkValue string mandatory Bookmark value.

Sample Code:

irpa_word.document.setBookmarkValue(oBookmarkName, bookmarkValue);

Errors:

Error Class Package Description
SequenceError irpa_core The Word Application and the current document must be defined