Skip to main content

Hi,

I need to add images from my local desktop to an excel file using automation anywhere. I tried to do this using the screen recorder and automating the clicks to insert an image, but this method is not very reliable because I am running this bot on a server that has a different version of excel than the one that I am building the bots on, therefore the UI does not align and the screen recorder does not work.

I know that there exists a bot in the bot store that adds images from your local PC to an excel file, but this bot is also unreliable because you can not reliably resize the images without killing the image resolution and making the image unreadable.

Does anyone know of any other alternate methods for adding an image file from your local PC to an excel file using AA?

Hi @Uzumaki,

 

Adding images to an Excel file using Automation Anywhere can indeed be tricky, especially with different Excel versions. Here’s an alternative approach that might be more reliable

 

Using Python Script with Automation Anywhere

You can leverage Python to insert images into an Excel file and then call this script from your Automation Anywhere bot

 

from openpyxl import load_workbook
from openpyxl.drawing.image import Image

def insert_image(excel_path, image_path, cell):
    # Load the workbook and select the active worksheet
    wb = load_workbook(excel_path)
    ws = wb.active

    # Load the image
    img = Image(image_path)

    # Add the image to the specified cell
    ws.add_image(img, cell)

    # Save the workbook
    wb.save(excel_path)

# Example usage
insert_image('path_to_excel_file.xlsx', 'path_to_image_file.png', 'A1')

 

 

  1. Create Variables:

    • Create variables for the Excel file path, image file path, and cell location.
    • $ExcelFilePath$, $ImageFilePath$, $CellLocation$
  2. Run Python Script:

    • Use the “Run Script” action to execute the Python script with the variables as parameters
    • Run Script - Script: insert_image.py, Parameters: $ExcelFilePath$ $ImageFilePath$ $CellLocation$

Reply