Dear Members,
I am using the following code to display photo from a folder in my excel sheet.
If I put a pdf file in the folder and try to fetch the image then I get " The picture cannot be displayed" error message.
I am looking for a solution which would show both images as well as PDF files.
Thank you so much.
Best Regards,
I am using the following code to display photo from a folder in my excel sheet.
VBA Code:
Sub DisplayMainPicture()
With Sheet1
On Error Resume Next
.Shapes("ReceiptPic").Delete
On Error GoTo 0
If .Range("I12").Value = Empty Then Exit Sub
PicPath = .Range("I12").Value 'Picture Path
If Dir(.Range("I12").Value, vbDirectory) = "" Then Exit Sub 'Exit on missing or incorrect file
On Error GoTo NoPic
With .Pictures.Insert(PicPath)
With .ShapeRange
.LockAspectRatio = msoTrue
.Height = 350
.Name = "ReceiptPic"
End With
End With
With .Shapes("ReceiptPic")
.Left = Sheet1.Range("K4").Left
.Top = Sheet1.Range("K4").Top
End With
NoPic:
End With
End Sub
If I put a pdf file in the folder and try to fetch the image then I get " The picture cannot be displayed" error message.
I am looking for a solution which would show both images as well as PDF files.
Thank you so much.
Best Regards,