Copying image to excel

Hi,

I have to copy paste an image to Excel sheet. How can I do this?

I tried creating a bit map new System.Drawing.bitmap(imageFile)

Invoke method SetImage for clipboard

In Excel application Scope
Select range A1
CTRL +V

It is not working. Please advise what I am doing wrong. Thank you,

@A_Learner

Try vba


Sub InsertImageIntoCell(imgPath As String, targetCellAddress As String)
    Dim ws As Worksheet
    Dim img As Object
    Dim targetCell As Range
    Dim cellLeft As Double
    Dim cellTop As Double
    Dim cellWidth As Double
    Dim cellHeight As Double

    ' Set your worksheet
    Set ws = ThisWorkbook.Sheets("Sheet1")
    
    ' Set the target cell
    Set targetCell = ws.Range(targetCellAddress)

    ' Get the cell's properties
    cellLeft = targetCell.Left
    cellTop = targetCell.Top
    cellWidth = targetCell.Width
    cellHeight = targetCell.Height

    ' Insert the image
    Set img = ws.Pictures.Insert(imgPath)
    
    ' Adjust the image size to fit the cell
    With img
        .Left = cellLeft
        .Top = cellTop
        .LockAspectRatio = msoFalse
        .Width = cellWidth
        .Height = cellHeight
    End With
End Sub

Note;: this is a chatgpt generated code

Cheers

VBA not allowed. Thank you.

Hi @A_Learner

Check the below thread:

Regards