cancel
Showing results for 
Search instead for 
Did you mean: 

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

DerekTeague
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
1 REPLY 1

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. 🙂