• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

what's mean about this error?

i have a error like:

exampleView.cpp(270) : error C2660: 'Add' : function does not take 0 parameters
E:\Microsoft Visual Studio\MyProjects\example\exampleView.cpp(279) : error C2660: 'Select' : function does not take 0 parameters
E:\Microsoft Visual Studio\MyProjects\example\exampleView.cpp(281) : error C2660: 'GetRange' : function does not take 1 parameters
E:\Microsoft Visual Studio\MyProjects\example\exampleView.cpp(284) : error C2660: 'GetRange' : function does not take 1 parameters
E:\Microsoft Visual Studio\MyProjects\example\exampleView.cpp(287) : error C2660: 'GetRange' : function does not take 1 parameters
E:\Microsoft Visual Studio\MyProjects\example\exampleView.cpp(294) : error C2660: 'GetRange' : function does not take 1 parameters
Error executing cl.exe.

example.exe - 6 error(s), 0 warning(s)

my source code is :
void CExampleView::OnExceloleExecute()
   LPDISPATCH pRange, pWorkbooks;
   CWnd* pWnd = CWnd::FindWindow("XLMAIN", NULL);
   if (pWnd != NULL) {
     TRACE("Excel window found\n");

   VERIFY(pWorkbooks = m_app.GetWorkbooks());

   LPDISPATCH pWorkbook = NULL;
   if (m_workbooks.GetCount() == 0) {
      // Add returns a Workbook pointer, but we
      //  don't have a Workbook class
      pWorkbook = m_workbooks.Add(); // Save the pointer for
                                     //  later release
   LPDISPATCH pWorksheets = m_app.GetWorksheets();
   ASSERT(pWorksheets != NULL);
   LPDISPATCH pWorksheet = m_worksheets.GetItem(COleVariant((short) 1));


   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A1")));

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A2")));
   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3")));

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3"),

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A6")));
   m_range[4].SetValue(COleVariant(COleDateTime(1998, 4, 24, 15, 47, 8)));
   // retrieve the stored date and print it as a string
   COleVariant vaTimeDate = m_range[4].GetValue();
   TRACE("returned date type = %d\n", vaTimeDate.vt);
   COleVariant vaTemp;
   vaTemp.ChangeType(VT_BSTR, &vaTimeDate);
   CString str = vaTemp.bstrVal;
   TRACE("date = %s\n", (const char*) str);

   m_range[0].SetValue(COleVariant("test string"));
   COleVariant vaResult0 = m_range[0].GetValue();
   if (vaResult0.vt == VT_BSTR) {
     CString str = vaResult0.bstrVal;
     TRACE("vaResult0 = %s\n", (const char*) str);

   COleVariant vaResult1 = m_range[1].GetValue();
   if (vaResult1.vt == VT_R8) {
     TRACE("vaResult1 = %f\n", vaResult1.dblVal);
   COleVariant vaResult2 = m_range[2].GetValue();
   if (vaResult2.vt == VT_R8) {
     TRACE("vaResult2 = %f\n", vaResult2.dblVal);

   COleVariant vaResult2a = m_range[2].GetFormula();
   if (vaResult2a.vt == VT_BSTR) {
     CString str = vaResult2a.bstrVal;
     TRACE("vaResult2a = %s\n", (const char*) str);
// cleanup  
    if (pWorkbook != NULL) {

void CExampleView::OnUpdateExceloleExecute(CCmdUI* pCmdUI)
   pCmdUI->Enable(m_app.m_lpDispatch != NULL);

void CExampleView::OnExceloleLoad()
{   // if Excel is already running, attach to it, otherwise start it
   CLSID clsid;
   TRACE("Entering CEx25dView::OnExcelLoad\n");
   ::CLSIDFromProgID(L"Excel.Application.8", &clsid); // from registry
   if(::GetActiveObject(clsid, NULL, &pUnk) == S_OK) {
            (void**) &pDisp) == S_OK);
      TRACE(" attach complete\n");
   else {
         if(!m_app.CreateDispatch("Excel.Application.8")) {
                  AfxMessageBox("Excel 97 program not found");
       TRACE(" create complete\n");

void CExampleView::OnUpdateExceloleLoad(CCmdUI* pCmdUI)
   pCmdUI->Enable(m_app.m_lpDispatch == NULL);

my helder file is:
// exampleView.h : interface of the CExampleView class

#if !defined(AFX_EXAMPLEVIEW_H__50D39E1F_48C9_11D3_BC81_00A00CC11E38__INCLUDED_)
#define AFX_EXAMPLEVIEW_H__50D39E1F_48C9_11D3_BC81_00A00CC11E38__INCLUDED_
#include "excel8.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CExampleView : public CView

   _Application m_app;
   Range    m_range[5];
   _Worksheet   m_worksheet;
   Workbooks   m_workbooks;
   _Workbook    m_workbook;
   Worksheets   m_worksheets;

protected: // create from serialization only

// Attributes
      CExampleDoc* GetDocument();

// Operations

// Overrides
      // ClassWizard generated virtual function overrides
      virtual void OnDraw(CDC* pDC);  // overridden to draw this view
      virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
      virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
      virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
      virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

// Implementation
      virtual ~CExampleView();
#ifdef _DEBUG
      virtual void AssertValid() const;
      virtual void Dump(CDumpContext& dc) const;


// Generated message map functions
       afx_msg void OnExceloleExecute();
     afx_msg void OnUpdateExceloleExecute(CCmdUI* pCmdUI);
     afx_msg void OnUpdateExceloleLoad(CCmdUI* pCmdUI);
       afx_msg void OnExceloleLoad();

#ifndef _DEBUG  // debug version in exampleView.cpp
inline CExampleDoc* CExampleView::GetDocument()
   { return (CExampleDoc*)m_pDocument; }


// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_EXAMPLEVIEW_H__50D39E1F_48C9_11D3_BC81_00A00CC11E38__INCLUDED_)

thank you ...

1 Solution
The function you're trying to run requires 2 parameters.

LPDISPATCH GetRange(const VARIANT& Cell1, const VARIANT& Cell2);

VERIFY(pRange = m_worksheet.GetRange(

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now