Skip to main content
Solved

Insert an image into word


Hi ,
 i want to insert an image into a word document using Automation anyhwere 360. I Installed a MS word package but it only had insert text, replace text options. 

Best answer by madhu subbegowda

Hi ​@amrutageorge 

I would recommed to use powershell script instead of Python as there would be a long term maintainance for updating packages etc. VB would slowdown the entire process. Below Power shell script might help you:

$word = New-Object -ComObject Word.Application
$word.Visible = $false
$doc = $word.Documents.Open("C:\Path\To\Your\Document.docx")
$selection = $word.Selection
$selection.InlineShapes.AddPicture("C:\Path\To\Image.jpg")
$doc.Save()
$doc.Close()
$word.Quit()

To run:

Use the “Run Script” action under System Package:

  • Type: PowerShell

  • Script Path: Path to your .ps1 file

View original

5 replies

DS78
Most Valuable Pathfinder
Forum|alt.badge.img+6
  • Most Valuable Pathfinder
  • July 15, 2025

I had a similar requirement. I did that using python and specifically python-docx library.


Hi ,
 i want to insert an image into a word document using Automation anyhwere 360. I Installed a MS word package but it only had insert text, replace text options. 

As there is no option to insert an image in A360, you can try to do it using either vb or python script and call that script from A360.

Refer python script below:

from docx import Document
from docx.shared import Inches

# Create a new Word document
doc = Document()

# Add a title or paragraph (optional)
doc.add_paragraph("Here's an image inserted using Python:")

# Insert the image
doc.add_picture('path/to/image.jpg', width=Inches(4.0))  # Adjust width as needed

# Save the document
doc.save('output.docx')
 

 


madhu subbegowda
Most Valuable Pathfinder
Forum|alt.badge.img+6

Hi ​@amrutageorge 

I would recommed to use powershell script instead of Python as there would be a long term maintainance for updating packages etc. VB would slowdown the entire process. Below Power shell script might help you:

$word = New-Object -ComObject Word.Application
$word.Visible = $false
$doc = $word.Documents.Open("C:\Path\To\Your\Document.docx")
$selection = $word.Selection
$selection.InlineShapes.AddPicture("C:\Path\To\Image.jpg")
$doc.Save()
$doc.Close()
$word.Quit()

To run:

Use the “Run Script” action under System Package:

  • Type: PowerShell

  • Script Path: Path to your .ps1 file


Hi, Thanks the powershell script worked


madhu subbegowda
Most Valuable Pathfinder
Forum|alt.badge.img+6

Great! Happy coding.