Run-time error 481 - Invalid picture

MarkCBB

Active Member
Joined
Apr 12, 2010
Messages
497
Hi there,

I am using some code I found on the internet, but I have made some samll changes to it and I am getting a Run-time error 481 - Invalid picture
Some of the Pitures do load but some of them dont load.

Here is the code I am using
Code:
Public Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
   ByVal szURL As String, _
   ByVal szFileName As String, _
   ByVal dwReserved As Long, _
   ByVal lpfnCB As Long) As Long
Public Sub GURoL(url As String, FileName As String)
Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, url, FileName, 0, 0)
    If lngRetVal <> 0 Then
    MsgBox "GURol godo: Can't download from " & url & " to " & FileName
    End If
End Sub
Sub Download_Procedure()
Dim MyPictureLink As String
Dim MyPictureName As String
Dim MyImage As Variant
'Please note I have removed the atual URl and replaced the text with MyUrlGoesHere
MyPictureLink = "MyUrlGoesHere" & Sheet8.Range("o156").Value
MyPictureName = Sheet8.Range("F2").Value

Call GURoL(MyPictureLink, "C:\testing\" & MyPictureName & ".Png")
Sheet7.Image1.Picture = LoadPicture("C:\testing\" & MyPictureName & ".Png")
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Can you add the Picture to the Image Control manually? Maybe you need to add a delay before you use LoadPicture.
 
Upvote 0
Hi Andrew,

I am not able to add it manually, I get a similar error "Invalid picture"
 
Upvote 0
How would I be able to find that out, as far as I can see it has the same properties of a Picture, If I navigate the to url using IE I am able to right click as save as Picture. the file name on the folder ends with .png
 
Upvote 0
Nope, I still get Invalid Image, maybe I sould rather use webbrowser to disaply instead of Image?
 
Upvote 0
Yup I tried to manually load the picture but Still not luck, going to try the web broswer approach now, But i seem to remember the last time I tried to load alot of picture into alot of Web browsers I got a Script error, but going to give it a go.
 
Upvote 0

Forum statistics

Threads
1,214,667
Messages
6,120,815
Members
448,990
Latest member
rohitsomani

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