FIX: Excel 2002 Series.ApplyDataLabels Method Generates Error on MFC Clients

This article was previously published under Q306659
This article has been archived. It is offered "as is" and will no longer be updated.
When you use DISPID binding that is based on an earlier version of the Excel type library to automate Excel 2002, you may receive the following error message when the program calls the ApplyDataLabels method of a Chart Series object:
0x80020003 (-2147352573): Member not found.
The DISPID for the ApplyDataLabels method of the Series object is changed in Excel 2002 so as not to conflict with a method by the same name on the Chart object. This change does not affect late bound clients, but does affect clients that are using cached DISPIDs (such as MFC wrapper classes). Because this change can break backward compatibility with already existing clients, Microsoft has issued a fix to resolve the issue.
To resolve this problem, obtain the latest service pack for Microsoft Office XP. For additional information, click the following article number to view the article in theMicrosoft Knowledge Base:
307841 OFFXP: How to Obtain the Latest Office XP Service Pack
The English version of this fix should have the following file attributes or later:
   Date         Time    Size         File name        ---------------------------------------------   SEP-18-2001  11:36   10,236,284   Q306659.msp				
After the hotfix is installed, the following files will have the listed attributes or later:
   Date         Time   Version      Size       File name        -----------------------------------------------------   SEP-13-2001  02:11  10.0.3311.0  9,165,128  Excel.exe   AUG-09-2001  19:28  10.0.3207.0  2,144,584  Graph.exe				

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
This problem was first corrected in Microsoft Office XP Service Pack 1.
Microsoft Foundation Classes (MFC) Automation projects that use Class Wizard-generated wrapper classes are commonly the projects that are at risk, because Class Wizard uses DISPID binding exclusively.

Steps to Reproduce Behavior

To reproduce the issue, you need to build an MFC project on a computer that has an earlier version of Excel (such as Excel 97 or Excel 2000). The problem is specific to clients that are made for those earlier versions and then used with Excel 2002.

  1. On a computer with Excel 97 or Excel 2000, use the MFC AppWizard to build a simple Dialog project. To make the basic program, use the steps that are detailed in the following Microsoft Knowledge Base article:
    178749 HOWTO: Create an Automation Project Using MFC and a Type Library
  2. Replace the code in the CAutoProjectDlg::OnRun() function with the following:
    void CAutoProjectDlg::OnRun(){   _Application oApp;   _Workbook oWB;   COleVariant covMissing((long)DISP_E_PARAMNOTFOUND, VT_ERROR);   COleVariant covIndex((long)1);   if (!(oApp.CreateDispatch("Excel.Application")))   {      AfxMessageBox("Can't create XL!");      return;   }   try   {      Workbooks oWBs;      _Worksheet oSheet;      Worksheets oSheets;      ChartObject oChartObj;      _Chart oChart;      Series oSeries;      oApp.SetVisible(TRUE);      oWBs = oApp.GetWorkbooks();      oWB = oWBs.Open("C:\\Chart.xls",             covMissing, covMissing, covMissing, covMissing,            covMissing, covMissing, covMissing, covMissing,             covMissing, covMissing, covMissing, covMissing);      oSheets = oWB.GetWorksheets();      oSheet = oSheets.GetItem(covIndex);      oChartObj = oSheet.ChartObjects(covIndex);      oChart = oChartObj.GetChart();      oSeries = oChart.SeriesCollection(covIndex);      oSeries.ApplyDataLabels(2, covMissing, covMissing, covMissing);      AfxMessageBox("If here, the method worked as expected.");   }   catch(COleException* pe)   {      AfxMessageBox("If here, you got the error!");      pe->ReportError();      pe->Delete();   }   if (oWB.m_lpDispatch)   {      oWB.SetSaved(TRUE);      oWB.Close(covMissing, covMissing, covMissing);      oWB.ReleaseDispatch();   }   oApp.Quit();   oApp.ReleaseDispatch();   return;}					
  3. Open Excel 97 or Excel 2000 and add the following data to cells A1:D4 of Sheet1:
                 June    July    August     Sally   34.56   56.76   23.54     Fred    45.76   47.23   39.65     John    42.23   38.43   51.87					
  4. Select the cells with the data, then click Chart on the Insert menu to start the chart wizard. Accept the defaults and click Finish to make a chart. Note that the chart should appear on the same sheet as the data.
  5. Save the workbook as C:\Chart.xls. If you name the workbook something else, or change its location, you need to modify the code in OnRun to point to the correct file name and path.
  6. Close Excel and switch back to the MFC project.
  7. Build the project and run the program. Note that the program runs correctly on a computer that is automating Excel 97 or Excel 2000.
  8. Move the MFC program to a computer that has Excel 2002. Copy the Chart.xls file to the same relative path on the new computer.
  9. Run the MFC program on the computer that is automating Excel 2002. Note that you receive the "Member not found" error message when the ApplyDataLabels method for the Series object is called.

Article ID: 306659 - Last Review: 10/24/2013 07:28:27 - Revision: 1.4

  • Microsoft Excel 2002 Standard Edition
  • kbnosurvey kbarchive kbhotfixserver kbqfe kbautomation kbbug kbfix kbofficexpsp1fix KB306659