Excel 2007 - Adding picture

rbriggs74

New Member
Joined
Nov 11, 2008
Messages
17
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
myDocument.Shapes.AddPicture _
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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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
myDocument.Shapes.AddPicture _
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.Open "HEAD", URL, False
W.Send
If W.Status = 200 Then
CheckURL = True
Else
CheckURL = False
End If
End Function
 
Upvote 0
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.
 
Upvote 0
'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
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,142
Members
448,551
Latest member
Sienna de Souza

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top