MFC Series Collection

  • Thread starter Thread starter Mardigin
  • Start date Start date
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
 
hi Mardigin

I too need to change the series labels in C++/MFC, and didn't manage to do it. Did you find the solution?

Thank you

Thibaud
 
Back
Top