Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

2 views
Skip to first unread message

phoen...@gmail.com

unread,
Jun 19, 2009, 5:58:18 AM6/19/09
to
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.

0 new messages