nkaggarwal1
New Member
- Joined
- Dec 9, 2018
- Messages
- 14
I am trying to extract the image from url and embed in excel 2007.
My Excel is simple , it contains 2 columns , Column 1 has the image url and in other column i want the embed the image. i am using the attached code , it is working perfectly fine for first row where i have saved the image from url in my local machine and given the path but fails when extracting from url.
Error - Run time 1004 , unable to get the insert property for the picture class.
Code Used-
Can this be problem with the excel vba references.
My Excel is simple , it contains 2 columns , Column 1 has the image url and in other column i want the embed the image. i am using the attached code , it is working perfectly fine for first row where i have saved the image from url in my local machine and given the path but fails when extracting from url.
Error - Run time 1004 , unable to get the insert property for the picture class.
Code Used-
Code:
Sub Button1_Click()
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
'On Error Resume Next
Application.ScreenUpdating = False
Set Rng = ActiveSheet.Range("A2:A3")
MsgBox "Step1"
For Each cell In Rng
filenam = cell
MsgBox "Step2" & cell
ActiveSheet.Pictures.Insert(filenam).Select
MsgBox "Step3"
Set Pshp = Selection.ShapeRange.Item(1)
'MsgBox "Step4" & Pshp
If Pshp Is Nothing Then GoTo lab
xCol = cell.Column + 1
Set xRg = Cells(cell.Row, xCol)
With Pshp
.LockAspectRatio = msoFalse
.Width = 80
.Height = 80
.Top = xRg.Top + (xRg.Height - .Height) / 2
.Left = xRg.Left + (xRg.Width - .Width) / 2
End With
Set Pshp = Nothing
Range("A2").Select
Next
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: