Vba Activate Chart Fails
I have a problem with an application that was created in Excel 2003 in my company. The application retrieves data from a source and updates a Chart using the SetSourceData in a VBA routine passing a Range containing the cells where the relevant data is written. The application runs just fine in Office 2003, but when the application is executed in Office 2010 it gives this error: Run-time error '1004': Method 'SetSourceData' of object'Chart' failed. I have created a For loop in a simple Excel file in Office 2010 and depending on the number of columns passed in the Range to the Chart the error will come up sooner or later. The more columns passed in the Range the sooner it will come up. I guess this has to be related with the number of series in the Chart(more columns more series). Is this some sort of mechanism/buffer in the Chart Object or Series implemented in Office 2010 that did not exist in Office 2003?
Technical Articles Creating Charts with VBA in Word..Chart ' Activate the data before you can access the workbook salesChart.ChartData.Activate.
VBA Charts - NewSeries - change ChartType - works in DEBUG (breakpoint) mode, but FAILS when RUN. I have a Excel VBA application which has been working fine in Excel 2003 but failed in Excel 2010. The relative codes are Public Sub Create_Chart Dim c Dim.
Excel Vba Activate
The same For loop never shows a problem when it is run in Office 2003 and I am not sure how to solve this problem. So far I have only been able to delete all the Series controlling the Error with a Goto instruction to delete all the series in the SeriesCollection using a For Each loop to select all the objects in the SeriesCollection of the Chart. If I do this and resume the execution of the application when I pass the Range again all the data is painted in the Chart Object properly. Example to reproduce the error. The following code is to be put in a VBA module in a new Excel 2010 workbook.
Run the Sub setDataChart and the application will run until the error message is displayed.