473,890 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Inli neShapes.AddOLE Object

(ClassType:="Ex cel.Chart", _
FileName:="", _
LinkToFile:=Fal se, _
DisplayAsIcon:= False, _
Range:=m_Applic ation.Selection .Range)
theNewShape.Wid th = theShape.Width
theNewShape.Hei ght = theShape.Height

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

Dim theObject As Object = thenewshape.OLE Format.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 7644
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.Inli neShapes.AddOLE Object
||
|| (ClassType:="Ex cel.Chart", _
|| FileName:="", _
|| LinkToFile:=Fal se, _
|| DisplayAsIcon:= False, _
|| Range:=m_Applic ation.Selection .Range)
|| theNewShape.Wid th = theShape.Width
|| theNewShape.Hei ght = theShape.Height
||
|| ' Store a reference to the OLE for later...
||
|| Dim theObject As Object = thenewshape.OLE Format.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.publi c.excel.program ming

--
Salut!
_______________ _______________ _________
Jean-Guy Marcil - Word MVP
jm***********@C APSsympatico.ca THISTOO
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
35580
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 and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
1
4369
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 to code a solution to this it'll probably be done in ASP on a web server, unless there's a significantly better way. I'm looking for a way to create over 100 Excel *charts* programmatically.
5
3208
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 to code a solution to this it'll probably be done in ASP on a web server, unless there's a significantly better way. I'm looking for a way to create over 100 Excel *charts* programmatically.
8
3862
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 as Object
17
6357
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
5809
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 SQL DATABASE, probably by the click of a button. Is this possible? & what is the BEST APPROACH for doing this? & also if any links are there do tell those to me too coz I have no idea how to go about doing it.
6
2411
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 automation. N.B. the environment is a totally enclosed intranet, all the client machines have WinXP, IE6 and Office Pro 2003 with all the latest SPs, and the IE security settings are sufficient to allow the Local Intranet Zone to instantiate...
3
3255
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
1763
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 the chart plotting part. Even though the code for generating the plot is fine, the routine does not like some chart required parameters such as .Axes(xlCategory, xlPrimary) .ChartType=xlXYScatter and the like. I need to plot a scattered...
0
9976
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9814
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10801
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10903
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8006
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7158
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6034
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4257
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.