By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,529 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,529 IT Pros & Developers. It's quick & easy.

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

P: n/a

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
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
jm***********@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.