H
Heath
Hi all,
sorry to dive straight in in my first post, but I joined up specifically
because I figured one of you would probably know how to do this and save me a
lot of messing about.
I have a fair amount of experience using VB.NET and would like to be able
to code a new type of chart in Excel (which I guess is most easily done using
VB script in Excel).
The Chart object accessible through VB script seems to be the obvious
starting place - I had imagined I would set a few simple properties (like
programatically setting the [Chart].Series.Values and [Chart].Series.XValues
propreties or pointing them to a cell range) and then call
ActiveSheet.Charts.Add method for my Chart object having overriden its Paint
method to provide the customised drawing.
Alas, no. For a start, VB script doesn't seem to really support OOP in the
same way .NET does, particularly when it comes to declaring and instantiating
a Chart object, so I've stumbled on even the first hurdle. Chart objects
can't be declared with the "new" keyword to instantiate them, so to avoid the
"object variable or with block not set" error I tried using the "set" keyword
to assign the return object from CreateObject("Excel.Chart") command to an
object variable. This seemedo far as it goes, but then every time I try to
access a property or method I get "Object does not support automation" errors
which Help tells me means that the Chart object doesn't expose the properties
and methods I want programatically (eems like a waste of time being able to
refer to it at all, if that's the case!) Maybe this is because the assignment
of the CreateObject object to an object variable using "set" is implicitly
late bound?
In any case, I want to be able to instantiate a Chart object and play with
its methods, properties and events programatically. In particular, to
override the events triggered when it redraws itself with custom code. Can
anyone help me out here?
Thanks for your time and expertise,
Heath.
sorry to dive straight in in my first post, but I joined up specifically
because I figured one of you would probably know how to do this and save me a
lot of messing about.
I have a fair amount of experience using VB.NET and would like to be able
to code a new type of chart in Excel (which I guess is most easily done using
VB script in Excel).
The Chart object accessible through VB script seems to be the obvious
starting place - I had imagined I would set a few simple properties (like
programatically setting the [Chart].Series.Values and [Chart].Series.XValues
propreties or pointing them to a cell range) and then call
ActiveSheet.Charts.Add method for my Chart object having overriden its Paint
method to provide the customised drawing.
Alas, no. For a start, VB script doesn't seem to really support OOP in the
same way .NET does, particularly when it comes to declaring and instantiating
a Chart object, so I've stumbled on even the first hurdle. Chart objects
can't be declared with the "new" keyword to instantiate them, so to avoid the
"object variable or with block not set" error I tried using the "set" keyword
to assign the return object from CreateObject("Excel.Chart") command to an
object variable. This seemedo far as it goes, but then every time I try to
access a property or method I get "Object does not support automation" errors
which Help tells me means that the Chart object doesn't expose the properties
and methods I want programatically (eems like a waste of time being able to
refer to it at all, if that's the case!) Maybe this is because the assignment
of the CreateObject object to an object variable using "set" is implicitly
late bound?
In any case, I want to be able to instantiate a Chart object and play with
its methods, properties and events programatically. In particular, to
override the events triggered when it redraws itself with custom code. Can
anyone help me out here?
Thanks for your time and expertise,
Heath.