Article ID: 238986 - Last Review: June 24, 2004 - Revision: 5.4

INFO: Translating Large Office Automation Error Values

This article was previously published under Q238986

On This Page

Expand all | Collapse all

SUMMARY

While automating an Office application, you might receive a large error value such as -2147221494. Troubleshooting the error is greatly facilitated by determining the exact description of the error. This article discusses several methods of obtaining the error messages associated with these large error values.

MORE INFORMATION

These large error values are known as HRESULTs and are defined in the header file Winerror.h. The numbers are so large because the first bit represents whether the number is an error result. You can use one of the following methods to obtain a description for the error.

Use the Error Lookup Utility

You can use the Error Lookup (ErrLook.Exe) utility that comes with Visual C++ to get meaningful descriptions of these errors:
  1. In the Visual C++ development environment, click Error Lookup on the Tools menu.
  2. Enter the error value, such as -2147221494, and click Lookup.
  3. The error message "Not able to bind to the source" for example, is returned.

Use FormatMessage() at Run-Time

If you want to programmatically obtain a description for an error, you can call the FormatMessage() API. For sample code and information about using FormatMessage(), click the article numbers below to view the articles in the Microsoft Knowledge Base:
186063  (http://support.microsoft.com/kb/186063/ ) INFO: Translating Automation Errors for VB/VBA (Long)
122957  (http://support.microsoft.com/kb/122957/ ) SAMPLE: Decode32 and Decode16 OLE Error Code Decoder Tools
If you are using Visual C++ 6.0, you can use the watch window to display the error message for an HRESULT. You can add an HRESULT to the Watch Window and append ", hr" (without the quotes) to it to have Visual C++ translate the error for you.

APPLIES TO
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 5.0 Professional Edition
  • Microsoft Visual C++ 4.0 Standard Edition
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Excel 2000 Standard Edition
  • Microsoft Excel 97 Standard Edition
  • Microsoft Office Access 2003
  • Microsoft Access 2002 Standard Edition
  • Microsoft Access 2000 Standard Edition
  • Microsoft Access 97 Standard Edition
  • Microsoft Project 2000 Standard Edition
  • Microsoft Outlook 2002 Standard Edition
  • Microsoft Outlook 2000 Standard Edition
  • Microsoft Outlook 97 Standard Edition
  • Microsoft Office PowerPoint 2003
  • Microsoft PowerPoint 2002 Standard Edition
  • Microsoft PowerPoint 2000 Standard Edition
  • Microsoft PowerPoint 97 Standard Edition
  • Microsoft Word 2002
  • Microsoft Word 2000
  • Microsoft Word 97 Standard Edition
Keywords: 
kbautomation kbfaq kbinfo KB238986
 

Article Translations