rbriggs74

New Member
Hello,

We the following macro code to place pictures in an Excel workbook the code to do this works in Excel 2002 but receives an error message in Excel 2007.

The code to place the picture is:

If CheckURL(v_url) Then
Set MyRng = Range("B" & rep_row)
v_left = MyRng.Left + 8
v_top = MyRng.Top + 12
v_url, _
True, True, v_left, v_top, 50, 50
Else

The error message says "The specified file wasn't found".

Any assistance would be appreciated.

Thanks,

Rick

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

texasalynn

Well-known Member
what is the rest of the code?

rbriggs74

New Member
Thanks for the quick response, here is the full code, including the CheckURL function (which seems to work). The code abends at the myDocument.Shapes.AddPicture statement.

Dim MyRng As Range
Dim v_top As Long
Dim v_left As Long

v_url = Worksheets("Master").Range("C" & i) + _
Worksheets("Master").Range("D" & i) + _
Worksheets("Master").Range("E" & i) + _
Worksheets("Master").Range("F" & i) + _
Worksheets("Master").Range("G" & i) + _
Worksheets("Master").Range("H" & i) + _
Worksheets("Master").Range("I" & i) + _
Worksheets("Master").Range("J" & i) + _
Worksheets("Master").Range("K" & i)

Set myDocument = Worksheets("detail")

If Left(v_url, 4) <> "http" Then
Worksheets("Detail").Range("B" & rep_row) = "No Picture Available"
Else
If CheckURL(v_url) Then
Set MyRng = Range("B" & rep_row)
v_left = MyRng.Left + 8
v_top = MyRng.Top + 12
v_url, _
True, True, v_left, v_top, 50, 50
Else
Worksheets("Detail").Range("B" & rep_row) = "Invalid URL - No Picture Available"
End If
End If

Function CheckURL(URL) As Boolean
'
' Haluk ® - 11/11/08
'
'
Dim W As Object
On Error Resume Next
Set W = CreateObject("winhttp.winhttprequest.5")
If Err.Number <> 0 Then
Set W = CreateObject("winhttp.winhttprequest.5.1")
End If
On Error GoTo 0

On Error Resume Next
W.Send
If W.Status = 200 Then
CheckURL = True
Else
CheckURL = False
End If
End Function

texasalynn

Well-known Member
sorry but I don't see where i is defined so the code gets stuck there, so seems like there is still some missing code.

rbriggs74

New Member
'i' is defined earlier in the macro and is an integer used as an index to report lines in a separate data worksheet. We are an SAP shop and this is a workbook that reformats lines that were returned from a query into a display that includes pictures of corresponding materials.

Thanks again,

Rick

Replies
0
Views
225
Replies
3
Views
1K
Replies
0
Views
191
Replies
2
Views
2K
Replies
1
Views
1K

1,191,532
Messages
5,987,123
Members
440,080
Latest member
drhorn4908

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back