473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 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 7596
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.