View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default LoadPicture() error XL2007

Nasty!
Try and identify where the problem starts from with something like this

Sub test()
Dim sPic As String
Dim ole As OLEObject
Dim stdPic As StdPicture

sPic = "C:\<path\myPic.jpg"

Set ole = ActiveSheet.OLEObjects("Image1")
Logit "ole.Name " & ole.Name, True
'Set stdPic = New stdole.StdPicture

Set stdPic = LoadPicture(sPic)
Logit "stdPic.Handle " & stdPic.Handle
Set ole.Object.Picture = stdPic
'or simply
'ole.Object.Picture = stdPic
Logit "ole.Object.Picture.handle " & ole.Object.Picture.Handle

End Sub

Function Logit(s As String, Optional bNew As Boolean)
Dim sLog As String
Dim ff As Integer

sLog = Application.DefaultFilePath & "\Logit.txt"
If bNew Then
On Error Resume Next
Kill sLog
On Error GoTo 0
End If

ff = FreeFile
Open sLog For Append As #ff
Print #ff, s
Close #ff

End Function

Regards,
Peter T

"Dave Unger" wrote in message
...
Hello,

I have an ActiveX image control (“stuGraphic”) on a worksheet
“wsStudent”.

The following line of code is run from a macro:

wsStudent.OLEObjects("stuGraphic").Object.Picture = LoadPicture()

Running with XL2007, this runs without fail 95% of the time, but
occasionally it generates an error message ‘Runtime error-2147417848
(80010108) Method “Picture” of object “IImage” failed.’ Once I get
the error, it fails continually - restarting the application, or
closing & restarting Excel does not fix the problem. The only fix
I’ve found to date (besides re-booting the computer) is to start up an
identical backup of the application, which runs without error. Now,
when I go back to the original, it runs without a hitch.

I’ve been playing with this for days, but can’t replicate the error,
it just seems to occur without warning. I’ve set up this line in a
test loop, it will run for hours without failing. I’m starting to
suspect a memory leak of some kind in my main application.

Oddly enough (maybe not), I’ve yet to have a failure running the same
code under XL2003.

If anyone can shed some light on this, I’d be most appreciative.
Thanks in advance.

Regards,

DaveU