Used Excel range as Bitmap Image

Hi everyone,

I need guidance on how to extract the Used Range from an Excel sheet as an image and then append or paste that image into a Word document.

I’m able to get the Used Range successfully, but I’m not sure how to convert or save it as an image variable and then pass it to Word for insertion.

1 Like

FYI : I have used help of chatgpt for your issue, please kindly let me know if any of the below options worked for you!!

happy Automation!!

:white_check_mark: Option 1: Use Excel’s native “Copy as Picture” feature (via VBA or UiPath activities)

Steps

  1. Use Excel Application Scope
    Open your Excel file using the Excel Application Scope.
  2. Get Used Range
  • Use Read Range (without specifying a range) to get the used range.
  • Optionally, store the address of the used range using an Invoke Code or Get Workbook Sheets activity if needed.
  1. Use VBA to Copy as Picture
  • Add an Invoke VBA activity.
  • Create a simple VBA code like this:
Sub CopyUsedRangeAsPicture()
    Dim ws As Worksheet
    Set ws = ActiveSheet
    ws.UsedRange.CopyPicture Appearance:=xlScreen, Format:=xlPicture
End Sub
  • Save this code in a .vbs or .txt file and point your Invoke VBA activity to it.
  1. Paste the Copied Picture to a Temporary Excel Chart
  • Add another VBA snippet to paste and export it as an image:
Sub SaveUsedRangeAsImage()
    Dim ws As Worksheet
    Dim ch As Chart
    Set ws = ActiveSheet
    ws.Paste
    Set ch = ws.ChartObjects.Add(0, 0, ws.UsedRange.Width, ws.UsedRange.Height).Chart
    ch.Paste
    ch.Export Filename:="C:\Temp\UsedRange.png", FilterName:="PNG"
    ch.Parent.Delete
End Sub
  • This will save your used range as an image (UsedRange.png).
  1. Insert the Image into Word
  • Use Word Application Scope.
  • Then use the Add Picture or Insert Image activity to paste the saved image.

:white_check_mark: Option 2: Use the UiPath Screenshot Method (simpler but less precise)

If you don’t need pixel-perfect export:

  1. Open Excel and Select Used Range using Select Range activity.
  2. Send Hotkey: Ctrl + Shift + Space (select entire used range if dynamic).
  3. Use Take Screenshot activity (from UiPath.Core.Activities).
  4. Store the image output in an Image variable (e.g., imgExcelRange).
  5. Save Image activity to save it as a file (e.g., C:\Temp\UsedRange.png).
  6. Insert Image into Word as above.

This approach is faster but depends on screen resolution and Excel window state.


:white_check_mark: Option 3: Use Python or .NET Interop for High Quality Export

If you want programmatic precision (for example, to generate reports automatically):

  • Use a Python Script activity with the openpyxl + matplotlib approach to render the DataFrame as an image.
  • Save as .png, then insert into Word.

:brain: Pro Tips

  • Make sure Excel is visible (set “Visible” = True) when using CopyPicture or Screenshot approaches.
  • You can dynamically create filenames using:
"C:\Temp\UsedRange_" + Now.ToString("yyyyMMdd_HHmmss") + ".png"
  • Always close Excel properly (use “Close Workbook”) before opening the image in Word.

Hi,

Can you try the following sample?

Sample
Sample20251114-1.zip (14.0 KB)

Regards,

@Srija, I am also searching for a direct UiPath Activity to perform this task, but I think there is no such activity available and using VBA is ok, but here I am facing the Trust Centre Issue in Excel.

Excel interop won’t give you a raw image, so the usual move is UsedRange.CopyPicture(...) → pull the bitmap from the clipboard → hand it off to word. either save it to a temp png and call InlineShapes.AddPicture, or skip the file entirely and just do word.Selection.Paste() right after the copy. that’s basically the only clean path unless you dive into openxml.

Can you elaborate this process a bit more?

I can show you some new method, with another tool , which is quite simple to do this.

Yes I am seraching for a solution. Please let me know.