Excel .Net late bound Series prop fails to recognize range object

B

BobH

Hello,
I've run into a problem with an application that I'm writing where it
seems that the interop services are having trouble in one very specific area.
To be more specific, I have a late bound Series object for a chart I created
and want to set the XValues and Values properties (each) to a set of range
objects I captured previously. The series object is part of a Series
Collection for an xlScatter plot, and is not the 1st series in the
collection. I can use the range objects I have, in other method calls and
can effectively use them as range objects. Everything in my application,
however, is late bound - in order to be able to use this application across
multiple office revisions. So, the range objects, and all other Excel
objects are all referenced by generic Object variables declared in my code.
The problem, as it seems, is that the XValues and Values properties are
overloaded to accept either arrays or range objects, and the range objects I
am passing in aren't being recognized by these properties. In fact, they are
recognized as not being arrays and not as range objects,... resulting in the
application throwing an exception. So, I am stuck. Just to clarify one
point, the first series on the chart is created by setting the source data
for the chart (which only expects a range object) and doesn't have a problem.
The typical approach I would normally take thereafter for subsequent series
on that chart would be to use the NewSeries method and set the properties of
that new series accordingly (this is what I normally would do in a VBA
macro). Since I can't seem to do this from .Net, I've experimented with
using the Add method to the series collection object and passing the union of
the X and Y range variables as the source data to the new series. This
fails, because it immediately assumes the X and Y data to be each a new
series plots them separately... with no option for recovery. If I (instead)
only pass in Y data to the NewSeries method, and attempt to set the XValues
property of that new series object after, I still get the same issue where
the range object representing the X data is not getting recognized as a Range
object... In short I still have no way to add a second X Y scatter series
to the plot from my late bound .Net code. Finally, my current development
setup consists of .Net ('03) and Office Pro '07. I am late binding to avoid
as many issues as possible with running under older versions of Office. With
respect to the problems in getting the Series object XValues and Values
properties to accept the range objects in this scenario, any ideas you can
share would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top