Question : MSExcel range error running VBA in MSAccess application

The bug report:
App: OTMD   Version: 5.97f
User: Admin
Machine: RADCON1
OS:  Win2000Pro
OffVer:  Office 97, SP3
JetVer:  Jet 3.61
Procedure/Function: bas_Report_RTA.RTA_WSPCPRefSumm
Error #-2147417851
Error Text:
Method '_Default' of object 'Range' failed

The Errant Line:  (Other lines like this fail also)
tsheet.Range("N8") = "=if(J8=0," & Chr(34) & Chr(34) & ",K8/J8)"

tsheet is an Excel Worksheet object instantiated from the parent tbook(Workbook), grandparent txl (New Excel.application)

This error occurs at irregular intervals on a "power Machine"  Intel2.8MHz, 1.2Gb of RAM

The app will raise the error, but if you wait as little as one second to go back and re-run the same line of code it will process without issue.

This seems to workaround it for now:
 
Routine_Err:
  select case err
  case -2147417851
    doevents                              '<---
    dbengine.idle                       '<---
    xlErrCount = xlErrCount +1  '<---I'm keeping track.....
    resume                                 '<---
  case else
    errmsg "bas_Routines.RTA",error$,err,true
    resume Routine_Exit
    resume
  end select

While this workaround does it for now, is there an actually solution for the cause?

Answer : MSExcel range error running VBA in MSAccess application

<<How's that for gremblins for you!?>>

That is what you have to love about Access. You can have some obscure bug that either can't be traced down or can't readily explain.

I personally can't explain why it is working the way it is. If you have a work-around, that is probably the best you will get.

Joe
Random Solutions  
 
programming4us programming4us