ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with setting chart size in VB.NET (https://www.excelbanter.com/excel-programming/351546-problem-setting-chart-size-vbulletin-net.html)

XxLicherxX

Problem with setting chart size in VB.NET
 
Hello everyone,

I am using VB.NET to automate the create of Excel files. The file that
I am creating has many charts in it. I am having a problem setting the
chart size. I am trying to do this with ChartArea.width. The problem is
everytime I even refer to ChartArea.width (or anything having to do
with ChartArea) the program crashes and gives me the error:

An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in CSTXL.exe

Additional information: Exception from HRESULT: 0x800401A8.


What does this error even mean and what can I do about it?

Here is how I am creating the chart:

oResizeRange = oWS.Range(RangeString)

oChart = oWS.Parent.Charts.Add
With oChart
.ChartWizard(oResizeRange, Excel.XlChartType.xl3DColumn, ,
Excel.XlRowCol.xlColumns)
oSeries = .SeriesCollection(1)
oSeries.XValues = oWS.Range(xValueStart, xValueEnd)
.SeriesCollection(1).Name = ChartName
.Location(Excel.XlChartLocation.xlLocationAsObject ,
oWS.Name)
.ChartArea.Width = 100 '<--------------- CRASH

End With

Thanks



All times are GMT +1. The time now is 03:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com