Help and Support

Error message when using XlCoerce with Excel 97: "Unhandled Exception in Mso97.dll"

Article ID:166287
Last Review:October 12, 2007
Revision:1.3
This article was previously published under Q166287
On This Page

SYMPTOMS

When you use XlCoerce in a dynamic-link library (DLL) that is loaded by Microsoft Excel 97, the following error message appears
Unhandled exception in excel.exe (MSO97.DLL): 0xc0000005: Access Violation
and Microsoft Excel stops responding.

Back to the top

CAUSE

This problem occurs when the following conditions are true:
You are using Microsoft Excel 97.
The DLL function is called from a worksheet as a result of a calculation.
You are trying to use XlCoerce to coerce a reference XLOPER that refers to a range that contains text.

Back to the top

RESOLUTION

To correct this problem, install Microsoft Excel 97 Service Release 1 (SR- 1).

To temporarily work around this problem, use one of the following methods.

Back to the top

Method 1

If XLOPER does not reference any cells that contain text, use the following function to determine whether to use XlCoerce:
        /*********
      *  RangeContainsText
      *
      *  Purpose: Determine if a XLOPER reference points to a range that
      *           contains any cells containing text.  Microsoft Excel 97
      *           stops responding if XlCoerce is used to convert a
      *           reference to a string.
      *
      *  Parameter:
      *           pxRange[in]    Range to check.
      *
      *  Return:  TRUE  -  Range contains text, or Excel4 call fails.
      *           FALSE -  Range does not contain text and it is safe to
      *                    use XlCoerce on the reference as a workaround
      *                    to the problem.
      *
      *******************************************************************/ 
      BOOL RangeContainsText(LPXLOPER pxRange)
      {
         DWORD dwRet = 0;
         XLOPER xIsText;
         BOOL bRet = TRUE;  // Value returned if Excel4 Fails

         // Check determine whether you are working with a range
         if( !((xltypeSRef | xltypeRef) & (pxRange->xltype)))
            return bRet;

         dwRet = Excel4(xlfIstext,&xIsText,1,pxRange);
         if( xlretSuccess == dwRet && xltypeErr != xIsText.xltype)
         {
            XLOPER xRet;
            dwRet = Excel4(xlfOr,&xRet,1,&xIsText);
            if( xlretSuccess == dwRet && xltypeBool == xRet.xltype)
               bRet = xRet.val.bool;
         }
         Excel4(xlFree,0,1,&xIsText);
         return bRet;
      }
				

Back to the top

Method 2

Instead of using the R data type to pass a range or a cell that may contain text, use the OPER data type (P). This data type does not support references, but it does support arrays, numbers, Boolean values, and errors. For more information about the Register function, see the Microsoft

Excel Software Development Kit (SDK).

Back to the top

STATUS

Microsoft has confirmed this to be a problem in Microsoft Excel 97 for Windows. This problem was corrected in Microsoft Excel 97 SR-1.

For more information about SR-1, click the following article number to view the article in the Microsoft Knowledge Base:
172475 (http://support.microsoft.com/kb/172475/) How to obtain and install Microsoft Office 97 SR-1

Back to the top


APPLIES TO
Microsoft Excel 97 Standard Edition
Microsoft Excel Software Development Kit 5.0

Back to the top

Keywords: 
kbbug kbdtacode kberrmsg kbfix kbprogramming KB166287

Back to the top

Article Translations

 

Related Support Centers

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.