Hello Experts,
I’m creating a report where I’m adding screenshot’s in an excel file
The issue is the image is pasting too big but i want it in 10*10 cell size
How to resolve this please don’t suggest VBA Scripting. I don’t want my workflow to be complex
without vba there is no way you can resize with inbuilt activities
cheers
I’ll try with VBA then
Here is an approach my side:
Assign the Image Path:
imgPath = System.IO.Path.Combine(Environment.CurrentDirectory, "Data\inputImg.png")
Create a VB Script File (.vbs) with the following code:
The code was generated by LLM, but debugged personally
Sub InsertImage(imgPath As String)
Dim ws As Worksheet
Dim img As Object
Dim topLeft As Range
Dim bottomRight As Range
Dim targetWidth As Double
Dim targetHeight As Double
' Set worksheet (change "Sheet1" if needed)
Set ws = ThisWorkbook.Sheets("Sheet1")
' Define top-left and bottom-right cells of the 10x10 range
Set topLeft = ws.Range("B2")
Set bottomRight = ws.Cells(topLeft.Row + 9, topLeft.Column + 9)
' Calculate target width and height
targetWidth = bottomRight.Left + bottomRight.Width - topLeft.Left
targetHeight = bottomRight.Top + bottomRight.Height - topLeft.Top
' Insert image
Set img = ws.Pictures.Insert(imgPath)
' Resize and position
With img
.Left = topLeft.Left
.Top = topLeft.Top
.Width = targetWidth
.Height = targetHeight
End With
End Sub
Use the Invoke VBA activity
THE OUTPUT:
Note: The output didn’t fit the image width to 10 cells because of the image i’ve opted for. Do let me know, if it works for you or not.
If this solves your issue, Do mark it as a solution.
Happy Automation ![]()
Thanks it’s working i made some changes in VB script.
one more thing here i’m using row count to paste the images but as one image takes 9*9 cells, it’s not considering the empty rows can you suggest anything
I didn’t quite get you.
Can you attach a screenshot ? (Censor any sensitive data).
Here i want the screenshots in A1,A11,A21,A31 for this logic i have used sheet.rowcount +10, I couldn’t achieve it
sheet.Rowcount + 10 inside the VBA will not make sense.
You have to do it outside, where the Loop is.
Here is an outline of the logic, I would recommend: (of course change it to your liking)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.



