View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
ememcee ememcee is offline
external usenet poster
 
Posts: 1
Default Error 50290: Error writing to Worksheet while using an ActiveX Control

I had this exact error happen to me this week, and found it rathe
frustrating to say the least. Reading this thread at least made i
clear that it is a known MS problem. I also could not find any Englis
version of the above mentioned MS KB article, but I do have a Japanes
technical contact who kindly sent me a translation. Here it is:
================================

The run-time error 50290 could occur when executing an Excel macr
created by Excel 2000 or an earlier version on Excel 2002. This i
because of a specification change of automation processing in Exce
2002.

When an automation related method is called, or when an automatio
related property is set, Excel 2002, as an automation server, firs
checks whether Excel is doing another processing such as handling dat
input by user. In case of a program that handles some events durin
communication with an external component such as ActiveX Control, Exce
can sometimes be unavailable temporarily. If automation communicatio
is requested at this timing, Excel will return this run-time error.

Solution is to check the Ready property to run your code only whe
Excel is ready for automation communication. This property is newl
available with Excel 2002. Here's a sample program on how to use th
Ready property.

'When Excel version is 2002 or later
If Val(Application.Version) = 10 Then

'Check the application status to see if it is available fo
processing.

If Application.Ready = True Then
<Describe what you want to do here
End If

'When Excel version is 2000 or earlier, continue the processing
Else
<Describe what you want to do here
End If

Note 1: There is no way to know at what timing the Ready property ca
become false. When you run a program that makes some events happe
during communication with an external component, it is recommended tha
you add a statement to make sure the Ready property is true.
Note 2: The sample program above will not do anything when the Read
property is false. If you want to force changing the value from fals
to true, you need to add additional codes doing so, such as sending a
Esc key by the Sendkeys statement.

=====================

--
Message posted from http://www.ExcelForum.com