How to use blue prism to insert an image to a Word file

VJR

Well-Known Member
The code I used is just the one you provided previously. The document is not the read-only document, but it will popup a dialog box which shows "which type do you want to open this file?" . Below it shows three choice to select. However when I select it, the error comes out. What's more , the correct result will show in a read-only but same-named word file which occurs suddenly.And it needs to "save as" as a Word opreation .
By the way, when I try to insert the image to an Excel file as a second choice, I also meet some problems. And I post them to that page.
This's the link :
http://www.rpaforum.net/threads/write-images-to-excel.958/
Thanks for your help again.
Hi lee,

The problem you are facing while saving the word document is due to this and the solution is also mentioned on the same post.
 

lee

New Member
Hi lee,

The problem you are facing while saving the word document is due to this and the solution is also mentioned on the same post.
After seeing that post,I have another question now.So does it mean I need to execute the "kill process" action by task manager or there is an action in the Word VBO I don't find ?
 

VJR

Well-Known Member
After seeing that post,I have another question now.So does it mean I need to execute the "kill process" action by task manager or there is an action in the Word VBO I don't find ?
There is an action in the Utility - Environment. Also you will find some examples on the forum on how to use it.
 

lee

New Member
There is an action in the Utility - Environment. Also you will find some examples on the forum on how to use it.
Hi, I find an interesting problem. When I use this code, I can't even insert it because the question I described previously. Even a new document and the first time to use can meet the "document can only be read-only" question and I want to know why and how to solve it .And it happens in a process I use word VBO, is it possible that I use a wrong way to build such a word-based process?.However, in the Word VBO, all things go through smoothly. It only happens when I use it as an action in the process.
Thanks.
 
Last edited:

argha.de

New Member
This is in continuation to your other post where you are getting the image to a file on the data item called FullSavedScreenshotPath.

i. Once that is done create a new action in the Object Studio
View attachment 1686

ii. Start stage Input parameters
View attachment 1687

iii. Code stage Input parameters
View attachment 1688

iv. Code stage:
This is just a basic skeleton and you need to amend it as necessary.

Code:
   Dim objWord as Object ' Word.Application
   Dim objDoc as Object     ' Word.Document  
   Dim objShapes as Object 'Shape object

   objWord = CreateObject("Word.Application")

   objDoc = objWord.Documents.Open(Document_File_Full_Path)

   objWord.Visible = True  
     
   objShapes=objDoc.InlineShapes.AddPicture (FileName:=Image_File_Full_Path, LinkToFile:=False, SaveWithDocument:=True)

   'Adjust the Height & Width as required
   'If both the below lines are commented then the original image is pasted as it is
   objShapes.Height = 300
   objShapes.Width = 500

    With objDoc
        .Save
        .Close
    End With

   objWord.Quit

   objWord = Nothing
   objDoc = Nothing  
   objShapes = Nothing


v. Output Word document
View attachment 1689


Hi @VJR ,
When I am trying to execute the above code it is giving me this below error in the code stage
Page: Action 1
Stage: Paste Image File To Documnet
Type: Error
Action: Validate
Description: Compiler error at line 5: 'CreateObject' is not declared. It may be inaccessible due to its protection level.
Repairable: No

Can you help me with this.
Many Thanks
 

Aman_123

New Member
Hi @VJR ,
When I am trying to execute the above code it is giving me this below error in the code stage
Page: Action 1
Stage: Paste Image File To Documnet
Type: Error
Action: Validate
Description: Compiler error at line 5: 'CreateObject' is not declared. It may be inaccessible due to its protection level.
Repairable: No

Can you help me with this.
Many Thanks
Hi argha,

Did you got any solution to above error ? i am getting same error?

Thanks
 

sivadilip97

New Member
This is in continuation to your other post where you are getting the image to a file on the data item called FullSavedScreenshotPath.

i. Once that is done create a new action in the Object Studio
View attachment 1686

ii. Start stage Input parameters
View attachment 1687

iii. Code stage Input parameters
View attachment 1688

iv. Code stage:
This is just a basic skeleton and you need to amend it as necessary.

Code:
   Dim objWord as Object ' Word.Application
   Dim objDoc as Object     ' Word.Document  
   Dim objShapes as Object 'Shape object

   objWord = CreateObject("Word.Application")

   objDoc = objWord.Documents.Open(Document_File_Full_Path)

   objWord.Visible = True  
     
   objShapes=objDoc.InlineShapes.AddPicture (FileName:=Image_File_Full_Path, LinkToFile:=False, SaveWithDocument:=True)

   'Adjust the Height & Width as required
   'If both the below lines are commented then the original image is pasted as it is
   objShapes.Height = 300
   objShapes.Width = 500

    With objDoc
        .Save
        .Close
    End With

   objWord.Quit

   objWord = Nothing
   objDoc = Nothing  
   objShapes = Nothing


v. Output Word document
View attachment 1689
I want to add several images with some headers how to do that ? Can you explain pls it will be helpful
 
Top