472,805 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

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


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
1 7531
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
1
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
5
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
8
by: deko | last post by:
When using automation (and especially with early binding) I've heard it is best to use explicit references to everything. For example: Dim xlChart as Excel.Chart rather than Dim objChart...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
6
by: Mark Rae | last post by:
Hi, My client has asked me to provide a "quick and dirty" way to export the contents of a DataGrid to both Excel for analysis and Word for editing and printing, so I'm investigating client-side...
3
by: saragoesnuts | last post by:
I have a program that automates to Excel with information in tables. I want to add charts to the excel file (pie charts, bar charts, etc). Is this possible?
5
by: hayuti | last post by:
I am developing a small routine that exports data from an Access database to Excel and plots a chart. At this stage the routine successful exports the data to excel but I am having a problem with...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.