cancel
Showing results for 
Search instead for 
Did you mean: 

Code for SaveAs of active word document of instance with known handle

DT
Level 4
MS Word is launched from SAP to display a document (path and file name is unknown). It will be the only instance of word running, so easy get  handle. But I want to save the active (only) open word document to a know path and filename.   So either a method to get the filepath and filename of the active document so I can use MS Word VBO SaveAs, or clone SaveAs to use active (only) open document. Any assistance appreciated. Thanks
3 REPLIES 3

VijayDodamani
Level 5
Hello DT, There is no by default method to get instance of active document. So as to save already opened document(Which is not opened by Blue Prism), we need to get first reference of the active document, Once we had the reference of active document then we can able to extract the path and name of active document. Here to create a scenario I just opened a new document and did not saved (manually, file name is ""Document1"") and trying to save it from Blue Prism. In this case we'll get only the Document name as an output, if opened document saved on different path and tried then we can able to get the path and name both. Below is the code: Please find the attachment for piece of code Here, DocumentName : Output of code stage; it will return the name of active document DocumentPath : Output of code stage, it will return the path of saved location Create a new action under MS Word VBO and paste the above code in code stage. Make sure you giving DocumentName and DocumentPath in Output tab of code stage. I hope this will work for your scenario. :)

rico.aj
Level 2

Hi @VijayDodamani , can you please upload again the attachment or the piece of code on how to handle this concern? Thank you in advance.

Hello Rico,

Normally when you open a file via SAP it is actually executing a temporary file that is stored in one of the standard folders (https://help.sap.com/docs/sap_gui_for_windows/dfad9ecd79db404eba46fdd709013a78/17c3a11c4ed249278dd36254bc136665.html)

What you can do is copy this file in the background and thus avoid screen interactions.

Regards,

Leonardo Soares RPA Developer América/Brazil