Excel Chart properties from VB.Net 2005

G

Guest

Hi,

I am trying to get a number of properties from a Chart in Excel from my
VB.Net application.

I can get the Chart Type and Chart Title, but need the following properties:

1) Check if the Data Labels show Percentage

2) Find out if the Chart is inserted as a New Sheet, and if so, what it is
called (Name)

3) Check if the Title has a Shadow Border around it

4) Find out the Series (Source Data) used for the Chart

Dim objExcelApp As Excel.Application = Nothing

Dim objWorkBook As Excel.Workbook = Nothing

objExcelApp = New Excel.Application()

objWorkBook = objExcelApp.Workbooks.Open(strFolder & "\ExcelData.xls")

Dim objChart As Excel.Chart = objWorkBook.Charts(1)

With objChart

MessageBox.Show(objChart.ChartType.ToString)

MessageBox.Show(objChart.ChartTitle.Text)

'Check if Data Labels show Percentage

'Get Source Data?

'Find out if Chart location is New Sheet, and if so, name of the Chart

'Check if Title has Shadow Border

End With

I have spent so many hours trying and searching for info, but no luck.

Any help would be much appreciated.

Thanks in advance,

Grant.
 
J

Jon Peltier

Open up Excel, make a chart, then record a macro while you apply these
various formats to elements in the chart. This gives you the VBA syntax for
these properties, and I'll leave it up to you to determine how VB.Net
renders this syntax.

For the source data, Excel does not expose this to VBA (or even to the UI if
the region is "too complicated to display"). You will have to parse the
series formulas of each series and reconstruct this range. John Walkenbach
has a class module that does the hard work for you:

http://www.j-walk.com/ss/excel/tips/tip83.htm

- Jon
 

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