Calling ApplyCustomType for Excel 2002 in C#

S

SJ

Hello, I'm trying to call the ApplyCustomType method in a C#
application using the Microsoft Excel 10.0 object library. I'm using
this method to use a user-defined chart type.

The method signature is
ApplyCustomType ( Excel.XlChartType ChartType , System.Object TypeName
)

What's throwing me is the first parameter. XlChartType is an
enumeration but there is no "user-defined" member. All members map to
a specific pre-defined chart type.

The code below was generated by running a VBA macro in Excel. The
ApplyCustomType method takes a value of xlUserDefined as the first
parameter.

Chart.ApplyCustomType(
ActiveChart.ApplyCustomType ChartType:=xlUserDefined,
TypeName:="ByVendor"

Does any know what to pass as the first parameter in ApplyCustomType
for C#?

Thanks,


Scott
 
B

Bill Manville

Sj said:
Does any know what to pass as the first parameter in ApplyCustomType
for C#?
22 ?

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup
 
R

Ron Howard

I ran into this problem developing a code-behind for a Word 2003
document. I was porting an existing Acces MSGraph Object and wanted to
keep the user-defined styles. To my Amazment the .NET Framework has not
included or included to the incorrect Enumeration the
XlChartType.XlUseDefined. The solution is as follows:

/************************************************************
* Cast as Graph.XlChartType the "XlUserDefined" Type
* defined in the Graph.XlChartGallery Enum.
*************************************************************/

object TypeName = "Test1";
oChart.Application.Chart().ApplyCustomType(((Graph.XlChartType)Graph.XlChartGallery.xlUserDefined),
TypeName);
 

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