• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Error - Import images in excel

sa.1985

Member
Dear All,
Hope you all are well!!

Subject: I am getting an error to importing images (An error occurred while importing this file. D:\A Suresh 2022 New Data\2022 New Data_Ariane_Suresh\Low_Resoution_Images/AMKARN0000.png)

Below is the code which i am Using.

>>> use code - tags <<<
Code:
Private Sub CommandButton1_Click()

Dim pictname As String
Dim pastehere As Range
Dim pasterow As Long
Dim x As Long
Dim lastrow As Long

lastrow = Worksheets("sheet1").Range("B1").CurrentRegion.Rows.Count
x = 2
For x = 2 To lastrow

Set pastehere = Cells(x, 1)

pasterow = pastehere.Row
On Error Resume Next
Cells(pasterow, 3).Select 'This is where picture will be inserted
pictname = Cells(x, 2) 'This is the picture name


ActiveSheet.Shapes.AddPicture Filename:="D:\A Suresh 2022 New Data\2022 New Data_Ariane_Suresh\Low_Resoution_Images \" & pictname & ".png", LinkToFile:=msoFalse, SaveWithDocument:=msoCTrue, Left:=Selection.Left + 8, Top:=Selection.Top + 8, Width:=50#, Height:=50#

Next
MsgBox ActiveSheet.Shapes.Count - 1
End Sub
 
Last edited by a moderator:
Back
Top