By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

VB.NET 2005 Excel Chart Object Syntax

P: 1
I am trying to automate an excel spreadsheet and then create a chart.

Dim chartRange As Excel.Range
If rollup Then
chartRange = sheet.Range("O2:Q14", Type.Missing)
chartRange.Select()
Else
chartRange = sheet.Range("N:N,M:M,A:A", Type.Missing)
chartRange.Select()
End If
excelBook.Charts.Add()
Dim chart As Excel.Chart = excelBook.ActiveChart
excelApp.ScreenUpdating = False
With chart
.Name = "TPE Graph"
.ChartType = Excel.XlChartType.xlColumnStacked100
.HasTitle = True
.PlotArea.Interior.ColorIndex = 0
.ChartTitle.Text = chartTitle

Dim xlAxisCategory, xlAxisValue As Excel.Axes
xlAxisCategory = chart.Axes(Type.Missing, Excel.XlAxisGroup.xlPrimary)
******* HERE IS ISSUE *****
xlAxisCategory = (.Axes(, Excel.XlAxisGroup.xlPrimary))
xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).HasTitle = True
xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).AxisTitle.Font.Bold = True
xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = "Week"
xlAxisValue = (.Axes(Type.Missing, Excel.XlAxisGroup.xlPrimary))
xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).HasTitle = True
xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).AxisTitle.Font.Bold = True
xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = "Actual Efficiency %"
.Legend.Position = Excel.XlLegendPosition.xlLegendPositionBottom




Dim tpeSeries, oppSeries As Excel.Series
tpeSeries = .SeriesCollection(1)
oppSeries = .SeriesCollection(2)
tpeSeries.Interior.ColorIndex = 10
oppSeries.Interior.ColorIndex = 3
If rollup Then
tpeSeries.Name = "TPE"
oppSeries.Name = "Opportunity"


End If
End With

I have checked the web and found many examples but the syntax does not seem to work. I am trying to use Excel.XlCategoryType.xlCategoryScale to get the X variables to scale by category so there are not large gaps between data plots since these are weekly totals. Any suggestions would be great


Thanks,
Apr 24 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.