ChartObjects property in a macro



I have attached a file. It is created from a template by writing values to individual cells on the "Data1" sheet. There is also a macro in the file that runs when the file is opened. This macro can also be triggered by clicking the "Show annotations" checkbox in the lower right corner.

(Please make sure to click inside the checkbox (even though it is little), otherwise the checkbox seems to disappear. (If this happens, don' t save the file when exiting)).

The attached file is created using Cells version Using this version I have a little problem with the above mentioned macro. The macro terminates with

"Run time error '1004': Unable to get the ChartObjects property of the Worksheet class".

The strange thing is that creating the file using the older version, version of the Excel component, everything works fine, the macro runs without any problem.

Since my problem is related to the newest version, would be excellent if you could look into this.

(My "plan" was to also attache the file created with the Excel version. I skipped it, as it seems that we can not attach two or more files. If this file will be useful, give me a hint, perhaps I can attach it in a separate post, relating it to this one).

Regards Edvin.


Hi Edvin,

Could you please post your template file which is not touched by Aspose.Cells? Thank you.


Hei again.

Here is the template file.

Regards Edvin.


Hi Edvin,

I opened your template file and got error in the same line of VBA code. So maybe this is a problem in your template file.


And what happens if you change your VBA code from:

Set pts = ActiveSheet.ChartObjects("Chart 1").Chart. _


Set pts = ActiveSheet.ChartObjects(1).Chart. _


Hei once again Laurence.

Yes, if the file is opened and macros enabled, one gets an error in the same line of VBA code. This is carelessness from my side. It can be avoided by setting the value in Cell "C1" to 0 (zero), saving and reopening.

But, an essential observation: When the template, as I shipped it, is opened, the error message is :

"Run-time error '1004' : Unable to get the Points property of the Series class"

In some way this is correct (if "C1">0), there are no points in the chart when it is empty.

But, note the difference from the other error message which says "... ChartObjects property ... Worksheet class".

So after Cells has written values, it seems to me that the macro can not find the Chart (as opposed to the Points).

(I also no attached the file created using Excel version, that works just fine, no problem running the macro).

I would appreciate very much if you could take another look. Excel v. handles this fine, Cells v. give me this little problem with accessing the chart from VBA code.

Regards Edvin.


Please try this attached version.


Hei again Laurence.

I have tested a few times. Problem solved. Thank you very much.

Regards Edvin.