Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
LoadPicture() error XL2007
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
LoadPicture() error XL2007
Dave Unger wrote:
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. I have not seen that particular one, but I have seen plenty like it. XL2007 graphics is a crock of ****. There are race conditions deep in the graphics code that allow objects to be manipulated before they have been fully instantiated. It seems to be worse on quad CPU kit. You could try adding a short delay before the failing line or a DoEvents to allow the system to catch up. I suspect that one of the reasons that charts in XL2007 are so glacially slow is to avoid it tripping up over race conditions when run on fast multiCPU boxes. Another indicator of a race condition is that it will always work OK if you step line by line in the debugger but fails sometimes at full speed. Regards, Martin Brown |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
LoadPicture() error XL2007
Hi Peter,
Thanks for your reply, I'll have a look at your suggestion. regards, DaveU On Apr 27, 3:55*am, "Peter T" <peter_t@discussions wrote: 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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
LoadPicture() error XL2007
Hi Martin,
Thanks for your reply. Your idea about "race conditions" makes a lot of sense, and I suspect this is at the root of the problem. Strangly enough though, once it's failed while running normally, I can't step thru it with the debugger either. Maybe something gets "broken" because of the "race" during the normal run. I'll certainly give your suggestions a try. Luckily, the client is running XL2003, which so far hasn't run into any problem with this application, but it does make me a bit nervous. Thanks for sharing your insights on this. regards, Dave On Apr 27, 6:55*am, Martin Brown wrote: I have not seen that particular one, but I have seen plenty like it. XL2007 graphics is a crock of ****. There are race conditions deep in the graphics code that allow objects to be manipulated before they have been fully instantiated. It seems to be worse on quad CPU kit. You could try adding a short delay before the failing line or a DoEvents to allow the system to catch up. I suspect that one of the reasons that charts in XL2007 are so glacially slow is to avoid it tripping up over race conditions when run on fast multiCPU boxes. Another indicator of a race condition is that it will always work OK if you step line by line in the debugger but fails sometimes at full speed. Regards, Martin Brown- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Code OK in XL2003 but Run-time error '1004' in xl2007 | Excel Programming | |||
LoadPicture fails | Excel Programming | |||
LoadPicture compile error | Excel Programming | |||
LoadPicture for a ControlButton help | Excel Programming | |||
LoadPicture - how to keep .jpg compression | Excel Programming |