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

lee

New Member
I want to know how to insert the image to the word file automatically in blue prism.
Thanks.
 

Sukesh Kumaru

Active Member
First make sure to store the image to a Data Item and then use this DI to write to word document.
or
Copy this image to clipboard and then use Get from Clipboard and write to word.
 

lee

New Member
First make sure to store the image to a Data Item and then use this DI to write to word document.
or
Copy this image to clipboard and then use Get from Clipboard and write to word.
Thanks. But how to write an image to a word? As I know, we only have the "type text " ,which can only input "text" type.
 

Sukesh Kumaru

Active Member
Hi All,

I have one predefined document, i just want to replace name and account number for every customer and send it back to customer,
how to replace the text from word document, kindly advise it.
Please post it separately, not in this thread.........
 

VJR

Well-Known Member
I want to know how to insert the image to the word file automatically in blue prism.
Thanks.
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 1534237288843.png

ii. Start stage Input parameters
View attachment 1534237350864.png

iii. Code stage Input parameters
View attachment 1534237386158.png

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 1534237603927.png
 

lee

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
Thanks a lot for your selfless help. I think I have solved the problems.
 
  • Like
Reactions: VJR

lee

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 . I have solved this problem, thanks a lot. However, there is another problem: the later image will cover the front one. After my tests, in the WORD VBO, the later contents will cover the front one , which contains images or words but both can be changed. So how to solve the problem of covering ? Expect your apply.
 
Last edited:

Devendhar

New Member
@VJR Thanks for your inputs for screen capture . I Have gone through the all step mentioned and implemented ,while running i'm getting below internal error .Could you please help us to resolved the below issue.

Internal : Could not execute code stage because exception thrown by code stage: Illegal characters in path.
 

VJR

Well-Known Member
I Have gone through the all step mentioned and implemented ,while running i'm getting below internal error
I am not sure which post and steps are you referring to. If it belongs to some other post can you submit it there with full details like what is the path you are giving.
 

Devendhar

New Member
@VJR : I'm sorry wrongly posted in this threads ,actually i'm facing the error screen capture for the below thread.
Procedute to take a Print screen & Store in Data Item Using Blue Prism
 

polugopi

New Member
i have a web application and it contains web table. the table contains hyperlink in first column.so, how can i click that first link in blueprism ?
 

VJR

Well-Known Member
Hi @polugopi, would you please open a new thread providing details about your issue as this thread is to 'insert image to a Word file'.
 

lee

New Member
Thanks a lot for your selfless help. I think I have solved the problems.
Hi, VJR. I met a new problem in this problem. When I tried to insert a picture to a word, it shows :
Internal : Could not execute code stage because exception thrown by code stage: The Save method or property is not available because the current document is read-only
And the picture will show in a read-only word file. And I don;t know how to solve it. Can you help me?
 

VJR

Well-Known Member
Hi lee,

Are you opening a document that is read-only Or is the document not closed thoroughly in the previous instance?
What is the complete code that you are using?
 

lee

New Member
Hi lee,

Are you opening a document that is read-only Or is the document not closed thoroughly in the previous instance?
What is the complete code that you are using?
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.
 
Last edited:
Top