[mso] Access Unbound Object Frame Fails to Open Excel Chart

I have isolated the problem to the "Forms!frmMainIO.cntlSchedule.Action = 
acOLEActivate" line of code you see in the function below. This is the code for 
chart 2. It appears that even with the 6 second or longer delay loop it is 
possible for the second chart to fail to activate with the error "2702-The OLE 
object isn't registered." To circumvent the problem I trap the failure of this 
command and try it again up to five times. In my testing it has only taken one 
retry to get the chart activated.
The delay loop is still needed. Without it I get a "memory cannot be read" 
error which cannot be trapped (I don't think).

My earlier belief that reactivating the Access window would solve the problem 
was a mistake. I believe that going back to the Access window simply gave the 
PC time/cycles/freedom to start the chart and register the OLE object under 
more normal conditions. Programmatically going back to the Access window was 
not always successful and I don't know why.


Function func_ActivateIOCharts()
    Dim strError As String, rtnVal As Variant
    Dim T1 As Variant
    Dim T2 As Variant
    Dim intRegisterCount As Integer
    
    intRegisterCount = 1

    On Error GoTo func_ActivateIOCharts_Error

'Chart 1 --------------
    Forms!frmMainIO.cntlDeals.Verb = acOLEVerbOpen
    DoEvents
    Forms!frmMainIO.cntlDeals.Action = acOLEActivate
    DoEvents
 
'Chart 2 --------------
    Forms!frmMainIO.cntlSchedule.Verb = acOLEVerbOpen
    DoEvents

' Delay Loop (6 seconds)
    T1 = Now()
    T2 = DateAdd("s", 6, T1)

    Do Until T2 <= T1
        T1 = Now()
        DoEvents
    Loop
    DoEvents

    On Error GoTo func_ActivateIOCharts_RegistrationError

TryAgain:
    Forms!frmMainIO.cntlSchedule.Action = acOLEActivate
    DoEvents
    
Exit Function

func_ActivateIOCharts_RegistrationError:
    intRegisterCount = intRegisterCount + 1
    If intRegisterCount < 6 Then GoTo TryAgain

func_ActivateIOCharts_Error:

End Function

Thanks to those who made suggestions.
Randy 



Randy Harding

Shell Trading US Company
909 Fannin St. - Suite 700, Houston, TX  77010, USA

Tel: +1-713-230 3114
Email: Randy.Harding@xxxxxxxxx
Internet: http://www.shell.com


*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, visit the group's homepage and use the dropdown 
menu at the top.  This will allow you to unsubscribe your email address or 
change your email settings to digest or vacation (no mail).
http://www.freelists.org/webpage/mso

To be able to share files with the group, you must join our Yahoo sister group. 
 This group will not allow for posting of emails, but will allow you to join 
and share problem files, templates, etc.:  
http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for FILE 
SHARING ONLY.

If you are using Outlook and you see a lot of unnecessary code in your email 
messages, read these instructions that explain why and how to fix it:
http://personal-computer-tutor.com/abc3/v28/greg28.htm
*************************************************************

Other related posts: