locked
Chart.ChartWizard() throw an exception indicate that ChartWizard() is not valid. RRS feed

  • Question

  • environment:
    Win2003ent  vc2005sp1 office2003sp3

    i wanna to operate excel from a dll. i generated MsExcel.h and
    MsExcel.cpp from excel's typelib. when running this code:

    COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
    VARIANT ret;

    ret = sheet.ChartObjects(covOptional);
    _MsExcel::ChartObjects chartObjects;//_MsExcel is my own's namespace
    chartObjects.AttachDispatch(ret.pdispVal);

    ret = chartObjects.Add(COleVariant(left), COleVariant(top), COleVariant
    (width), COleVariant(height));
    _MsExcel::ChartObject chartObject;
    chartObject.AttachDispatch(ret.pdispVal);

    ret = chartObject.GetChart();
    _MsExcel::Chart chart;
    chart.AttachDispatch(ret.pdispVal);

    _MsExcel::Range rng = sheet.GetRange(COleVariant(_T("A1")), COleVariant
    (_T("D4")));

    VARIANT var;
    var.vt = VT_DISPATCH;
    var.pdispVal = rng.m_lpDispatch;
    var.pdispVal->AddRef();

    chart.ChartWizard(
                    var,
                    COleVariant((short)54),
                    covOptional,
                    COleVariant((short)1),
                    COleVariant((short)0),
                    COleVariant((short)1),
                    COleVariant((short)TRUE),
                    COleVariant(_T("AAA")),
                    COleVariant(_T("BBB")),
                    COleVariant(_T("CCC")),
                    covOptional
                    );  //here throw an exception " ChartWizard is not valid"

    pls help me.

    • Moved by Sheng Jiang 蒋晟 Saturday, June 20, 2009 3:19 PM Not a Chinese question. Off-topic to Visual C++ forums. No office programming forum exist on the platforum. (From:Visual C++)
    Saturday, June 20, 2009 2:44 AM

Answers

  • Unfortunatley there is no forum here for the area you need help with. I suggest you go to the excel developer community instead.
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful. This posting is provided "AS IS" with no warranties, and confers no rights.
    Visual C++ MVP
    Saturday, June 20, 2009 3:26 PM
  • Or ask in the Excel dev forum on MSDN.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)

    Tuesday, August 14, 2012 2:34 AM

All replies

  • Unfortunatley there is no forum here for the area you need help with. I suggest you go to the excel developer community instead.
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful. This posting is provided "AS IS" with no warranties, and confers no rights.
    Visual C++ MVP
    Saturday, June 20, 2009 3:26 PM
  • Or ask in the Excel dev forum on MSDN.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)

    Tuesday, August 14, 2012 2:34 AM