Link to home
Start Free TrialLog in
Avatar of tewehuang
tewehuang

asked on

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");
     pWnd->ShowWindow(SW_SHOWNORMAL);
     pWnd->UpdateWindow();
     pWnd->BringWindowToTop();
   }

   m_app.SetSheetsInNewWorkbook(1);
   
   VERIFY(pWorkbooks = m_app.GetWorkbooks());
   m_workbooks.AttachDispatch(pWorkbooks);

   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);
   m_worksheets.AttachDispatch(pWorksheets);
   LPDISPATCH pWorksheet = m_worksheets.GetItem(COleVariant((short) 1));

   m_worksheet.AttachDispatch(pWorksheet);
   m_worksheet.Select();

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A1")));
   m_range[0].AttachDispatch(pRange);

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A2")));
   m_range[1].AttachDispatch(pRange);
   
   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3")));
   m_range[2].AttachDispatch(pRange);

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3"),
         COleVariant("C5")));
   m_range[3].AttachDispatch(pRange);

   VERIFY(pRange = m_worksheet.GetRange(COleVariant("A6")));
   m_range[4].AttachDispatch(pRange);
   
   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);
   }

   m_range[1].SetValue(COleVariant(3.14159));
   
   COleVariant vaResult1 = m_range[1].GetValue();
   if (vaResult1.vt == VT_R8) {
     TRACE("vaResult1 = %f\n", vaResult1.dblVal);
   }
   
   m_range[2].SetFormula(COleVariant("=$A2*2.0"));
   
   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);
   }
   
   m_range[3].FillRight();
   m_range[3].FillDown();
   
// cleanup  
    if (pWorkbook != NULL) {
          pWorkbook->Release();
   }
}

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
   LPDISPATCH pDisp;
   LPUNKNOWN pUnk;
   CLSID clsid;
   TRACE("Entering CEx25dView::OnExcelLoad\n");
   BeginWaitCursor();
   ::CLSIDFromProgID(L"Excel.Application.8", &clsid); // from registry
   if(::GetActiveObject(clsid, NULL, &pUnk) == S_OK) {
      VERIFY(pUnk->QueryInterface(IID_IDispatch,
            (void**) &pDisp) == S_OK);
      m_app.AttachDispatch(pDisp);
      pUnk->Release();
      TRACE(" attach complete\n");
  }
   else {
         if(!m_app.CreateDispatch("Excel.Application.8")) {
                  AfxMessageBox("Excel 97 program not found");
         }
       TRACE(" create complete\n");
   }
   EndWaitCursor();
}

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
{
private:

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

protected: // create from serialization only
      CExampleView();
      DECLARE_DYNCREATE(CExampleView)

// Attributes
public:
      CExampleDoc* GetDocument();

// Operations
public:

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

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

protected:

// Generated message map functions
protected:
      //{{AFX_MSG(CExampleView)
       afx_msg void OnExceloleExecute();
     afx_msg void OnUpdateExceloleExecute(CCmdUI* pCmdUI);
     afx_msg void OnUpdateExceloleLoad(CCmdUI* pCmdUI);
       afx_msg void OnExceloleLoad();
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
};

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

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// 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 ...

ASKER CERTIFIED SOLUTION
Avatar of Triskelion
Triskelion
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial