Creating and manipulating an Excel Chart in Microsoft Word using Automation from VB.NET.

R

Robin Tucker

Heres and interesting problem:

I have a VB.NET program that creates reports via. Word Automation. This all
works fine. What I want to do as part of this report generation process is
to embed a graph/chart within the report, once again from VB.NET. I have
chosen to use Excel.Chart.8. So, to embed I do this from VB.NET:

Dim theNewShape As InlineShape = m_Document.InlineShapes.AddOLEObject

(ClassType:="Excel.Chart", _
FileName:="", _
LinkToFile:=False, _
DisplayAsIcon:=False, _
Range:=m_Application.Selection.Range)
theNewShape.Width = theShape.Width
theNewShape.Height = theShape.Height

' Store a reference to the OLE for later...

Dim theObject As Object = thenewshape.OLEFormat.Object

I have no idea how to manipulate the data series/values from here on in.
I've spent all day pouring over inadequate Excel VBA documentation and
articles on the internet are scarce. I tried and failed to create series in
the series collection of my chart using VB arrays (its odd, even in the
"quick watch" debug window, changing the series.value(1) from a default
value of 0.0 to 1.0 works (ie. no error), but it changes itself back to 0
right away).

I'm completely confused about how to do this. Can anyone recommend a
tutorial or otherwise explain the basics of getting my data values
(essentially an array of doubles and an array of dates - temperature over
time) into an Excel.Chart control via. VB.NET automation?

I would really appreciate this.


thanks



Robin
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Robin Tucker > écrivait :
In this message, < Robin Tucker > wrote:

|| Heres and interesting problem:
||
|| I have a VB.NET program that creates reports via. Word Automation. This
all
|| works fine. What I want to do as part of this report generation process
is
|| to embed a graph/chart within the report, once again from VB.NET. I have
|| chosen to use Excel.Chart.8. So, to embed I do this from VB.NET:
||
|| Dim theNewShape As InlineShape = m_Document.InlineShapes.AddOLEObject
||
|| (ClassType:="Excel.Chart", _
|| FileName:="", _
|| LinkToFile:=False, _
|| DisplayAsIcon:=False, _
|| Range:=m_Application.Selection.Range)
|| theNewShape.Width = theShape.Width
|| theNewShape.Height = theShape.Height
||
|| ' Store a reference to the OLE for later...
||
|| Dim theObject As Object = thenewshape.OLEFormat.Object
||
|| I have no idea how to manipulate the data series/values from here on in.
|| I've spent all day pouring over inadequate Excel VBA documentation and
|| articles on the internet are scarce. I tried and failed to create series
in
|| the series collection of my chart using VB arrays (its odd, even in the
|| "quick watch" debug window, changing the series.value(1) from a default
|| value of 0.0 to 1.0 works (ie. no error), but it changes itself back to 0
|| right away).
||
|| I'm completely confused about how to do this. Can anyone recommend a
|| tutorial or otherwise explain the basics of getting my data values
|| (essentially an array of doubles and an array of dates - temperature over
|| time) into an Excel.Chart control via. VB.NET automation?
||

If I understand correctly, you want to generate a chart in Excel and then
Embed in Word without saving the actual Excel chart.
If I have missed your point, stop reading!

The easiest would be to create an excel Workbook, dump your data in a
worksheet, create a chart from that data and then embed the chart in Word
before quitting Excel without saving.

This is fairly straightforward Excel VBA.
To get more info on the particulars, you should post in an Excel workgroup
like
microsoft.public.excel.programming

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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