missing Excel 2000 properties and methods

G

Guest

I'm converting a vbscript program to vb.net. Witht he exception of .net
idiosyncrasies, most of it is working well with the same code. My only
problem is that some properties and methods are missing from the Chart
object. For instance, the following line worked fine in vbscript
(csPowerSpeed is the chart):

objXL.csPowerSpeed.seriescollection.newseries()

However, in VS.Net, newseries is no longer avaialable as a method for series
collection! The only options I have are Equals, GetHashCode, GetType and
ToString.

Same problem occurs with other properties and methods such as
Axes().Hastitle and ChartTitle.Characters.Text. In addition,
csPowerSpeed.HasTitle = True generates an error.

Here are my DIM statements:

Dim objXL As New Excel.Application
Dim wbOutput As Excel.Workbook = objXL.Workbooks.Add
Dim wsCSV As Excel.Worksheet = DirectCast(objXL.Worksheets(1),
Excel.Worksheet) 'temporary worksheet(s)
Dim wsGeneric As Excel.Worksheet = DirectCast(objXL.Worksheets(1),
Excel.Worksheet) 'generic worksheet object
Dim wsDataRed As Excel.Worksheet = DirectCast(objXL.Worksheets(1),
Excel.Worksheet) 'data reduction worksheet object
Dim wsStdDev As Excel.Worksheet = DirectCast(objXL.Worksheets(1),
Excel.Worksheet) 'standard deviation worksheet object
Dim csPowerSpeed As Excel.Chart =
DirectCast(objXL.Charts.Add(objXL.Worksheets(objXL.Worksheets.Count)),
Excel.Chart) 'power plot chart object
Dim csTorqueSpeed As Excel.Chart =
DirectCast(objXL.Charts.Add(objXL.Worksheets(objXL.Worksheets.Count)),
Excel.Chart) 'torque plot chart object

I have included Imports for the Office 2000 and Excel 2000 libraries in my
vb.net project. Workbook and worksheet functions all perform perfectly; only
charts have a problem. In addition, the properties and methods were all
available in my vbscript. Anyone have an idea what could be going wrong here?
 
G

Guest

nevermind-- solved it trough trial-and-error. Just DIMming seriescollection
and axes objects solved the problem, as shown:

Dim seriesPowerSpeed As Excel.SeriesCollection =
csPowerSpeed.SeriesCollection
Dim seriesTorqueSpeed As Excel.SeriesCollection =
csTorqueSpeed.SeriesCollection
Dim axesPowerSpeed As Excel.Axes = csPowerSpeed.Axes
Dim axesTorqueSpeed As Excel.Axes = csTorqueSpeed.Axes

The weird thing is I don't even need to use the variables for the
functionality to work as it should; just DIMming the variables seems to do
the trick. Go figure.

Hope this helps someone else!
 

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