INFO: Type Libraries for Office 2000 Have ChangedID: Q224925
|
The type libraries for the Microsoft Office 2000 products have changed since Microsoft Office 97. Although the Office 2000 type libraries contain the functions that were present in the Office 97 type libraries, there have been additions to the number of arguments for some functions. If you use ClassWizard-generated wrapper classes for an Office 2000 product with code that was developed for an Office 97 product, you might receive the following compilation error:
This error occurs because the Office 97 function required fewer arguments than the Office 2000 version of that function. This article describes how to correct these errors so that you can use code developed for an Office 97 product with the Office 2000 type library.error C2660: '(function)' : function does not take (n) parameters
One such function that has changed is the Microsoft Word 2000 Add method of the Documents object. If you've used the ClassWizard to generate class wrappers for the functions in the Microsoft Word 2000 type library and you use code that worked with Microsoft Word 97, you will receive the compile error previously described. The following describes how you can correct this problem. Note that although the case illustrated applies to code that specifically automates Word, the same information can be applied to the other Microsoft Office applications.
With the Word 97 type library, you could use the following code to automate Word and start a new document:
_Application oApp;
Documents oDocs;
_Document oDoc;
COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR),
vtTrue((short)TRUE),
vtFalse((short)FALSE);
// Create an instance of Word
if (!oApp.CreateDispatch("Word.Application"))
{
AfxMessageBox("Word failed to start!");
return;
}
// Add a new document and make Word visible
oDocs = oApp.GetDocuments();
oDoc = oDocs.Add(vtOptional,vtOptional);
oApp.SetVisible(TRUE);
If you attempt to run this code against the Word 2000 type library, you will receive the compile error C2660 "'Add' : function does not take 2 parameters" for the following line of code:
oDoc = oDocs.Add(vtOptional,vtOptional);
To correct this problem, you can perform the following steps.
oDoc = Docs.Add(vtOptional,vtOptional,vtOptional,vtOptional);
For more information on Office Automation, please visit the Microsoft Office Development support site at:
http://support.microsoft.com/support/officedev/
Keywords : kbAccess kbAutomation kbExcel kbMFC kbVC kbPowerPt kbWord kbGrpDSO
Version : WINDOWS:2000; winnt:
Platform : WINDOWS winnt
Issue type : kbinfo
Last Reviewed: June 30, 1999