MFC Series Collection

M

Mardigin

I have an xlColumns chart that I am programatically
generating with MFC. I want to be able to change the
Series labels in the legend to something other then
Serries1 and Serries2.

The following code seems to work in VB.

ActiveChart.SeriesCollection(1).XValues = "={""Date
someDate"","" Date SomeDate2"","" Date SomeDate3"","" Date
SomeDate4""}"

ActiveChart.SeriesCollection(1).Name = "=""MyTitle1"""

ActiveChart.SeriesCollection(2).XValues = "={""Date
someDate"","" Date SomeDate2"","" Date SomeDate3"","" Date
SomeDate4""}"

ActiveChart.SeriesCollection(2).Name = "=""MyTitle2"""

However I can't seem to figure out how to do this in MFC.

I noticed that the xl SerriesCollection Object has a
SetProperties Method. So I have tried the following, but
this does not work. I have a limited understanding of how
to talk to excel, so I would be very very happy if someone
could enlighten me a little.

VARIANT vResult; // A Struct with a pdispVal member

xlSeriesCollection.AttachDispatch(lpDisp);
DISPID dispID; // Temporary DISPID
unsigned short *ucPtr; // Temporary name holder

ucPtr = L"Name";
xlSeriesCollection.m_lpDispatch->GetIDsOfNames(IID_NULL,
&ucPtr, 1, LOCALE_USER_DEFAULT, &dispID);


xlSeriesCollection.InvokeHelper(dispID, DISPATCH_METHOD |
DISPATCH_PROPERTYGET,VT_VARIANT, (void*)&vResult, NULL);

xlSeriesCollection.SetProperty(dispID, vType, COleVariant
("MySerriesLabel"));

Thank you all kindly in Advance,

Mardigin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top