Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code OK in XL2003 but Run-time error '1004' in xl2007 Ken Johnson Excel Programming 0 July 22nd 09 01:00 PM
LoadPicture fails kirkm[_8_] Excel Programming 3 April 17th 09 04:28 AM
LoadPicture compile error Jim[_7_] Excel Programming 1 December 21st 07 12:17 AM
LoadPicture for a ControlButton help micmacuk Excel Programming 7 May 30th 06 08:44 PM
LoadPicture - how to keep .jpg compression No Name Excel Programming 0 May 25th 04 08:14 AM


All times are GMT +1. The time now is 09:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"