MS Word Chart filled with data - URGENT PLEASE  
Author Message
WiLD_THiNG





PostPosted: Thu Oct 05 00:56:07 CDT 2006 Top

Visual Basic [VB] >> MS Word Chart filled with data - URGENT PLEASE

My boss wants this done in a day. I would be happy with a week!

Anyway, I have a dataset filled with data and need to populate an MS word
chart with it when writing a report. Any tutorials or suggestions would be
great.

Sample data at http://www.hide-link.com/

Visual Studio126  
 
 
v-phuang





PostPosted: Thu Oct 05 00:56:07 CDT 2006 Top

Visual Basic [VB] >> MS Word Chart filled with data - URGENT PLEASE Hi,

Here I understand that you means the Chart that using Word Menu,
Insert/Picture/Chart.
So I think you may try to transfer the DataSet to a Excel Workbook and then
import the excel file into the Chart.

Here is a VBA macro for your reference, but it is easy to run the similar
code in VB.NET.

Sub Macro1()
Dim oChart As Graph.Chart 'Add reference to Graph Object library
Set oChart =
Selection.InlineShapes.AddOLEObject(ClassType:="MSGraph.Chart.8",
LinkToFile:=False, DisplayAsIcon:=False).OLEFormat.Object
oChart.Application.FileImport "C:\temp\TestABC.xls"
End Sub

How to automate Word from Visual Basic .NET to create a new document
http://support.microsoft.com/default.aspx?scid=kb;[LN];316383

How to automate Microsoft Word to perform a mail merge from Visual Basic
 
 
vbnetdev





PostPosted: Thu Oct 05 01:08:04 CDT 2006 Top

Visual Basic [VB] >> MS Word Chart filled with data - URGENT PLEASE Let me explain....the data gets moved to an access database from the csv
file. I will actually be reading it from the access database. The csv file
itself is not usable due to bad formatting and column names being too long.

Also, could you demonstrate formatting of the chart within .NET?

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com





> Hi,
>
> Here I understand that you means the Chart that using Word Menu,
> Insert/Picture/Chart.
> So I think you may try to transfer the DataSet to a Excel Workbook and
> then
> import the excel file into the Chart.
>
> Here is a VBA macro for your reference, but it is easy to run the similar
> code in VB.NET.
>
> Sub Macro1()
> Dim oChart As Graph.Chart 'Add reference to Graph Object library
> Set oChart =
> Selection.InlineShapes.AddOLEObject(ClassType:="MSGraph.Chart.8",
> LinkToFile:=False, DisplayAsIcon:=False).OLEFormat.Object
> oChart.Application.FileImport "C:\temp\TestABC.xls"
> End Sub
>
> How to automate Word from Visual Basic .NET to create a new document
> http://support.microsoft.com/default.aspx?scid=kb;[LN];316383
>
> How to automate Microsoft Word to perform a mail merge from Visual Basic
> NET
> http://support.microsoft.com/default.aspx?scid=kb;[LN];302816
>
> How to automate Microsoft Word to perform a mail merge from Visual Basic
> NET
> http://support.microsoft.com/default.aspx?scid=kb;[LN];301656
>
> Here is a link about how to transfer data into Excel Workbook in VB.NET.
> How to transfer data to an Excel workbook by using Visual Basic .NET
> http://support.microsoft.com/default.aspx?scid=kb;[LN];306022
>
> You may have a try and let me know the result.
>
> If I misunderstood or you have any conern on this issue, please feel free
> to let me know and I am glad to be of assistance.
>
>
> Best regards,
>
> Peter Huang
>
> Microsoft Online Community Support
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>


 
 
v-phuang





PostPosted: Thu Oct 05 22:58:31 CDT 2006 Top

Visual Basic [VB] >> MS Word Chart filled with data - URGENT PLEASE Hi,

Here I provide some code about insert a chart into Word document and import
excel data into the chart and then format it.

Imports Word = Microsoft.Office.Interop.Word
Imports Graph = Microsoft.Office.Interop.Graph

Module Module1

Sub Main()
Dim wdApp As New Word.Application
wdApp.Visible = True
Dim oDoc As Word.Document = wdApp.Documents.Add
Dim oInlineShape As Word.InlineShape =
oDoc.Content.InlineShapes.AddOLEObject(ClassType:="MSGraph.Chart.8",
LinkToFile:=False, DisplayAsIcon:=False)
Dim oChart As Graph.Chart = oInlineShape.OLEFormat.Object
oChart.Application.FileImport("C:\temp\TestABC.xls")
oChart.BarShape = Graph.XlBarShape.xlPyramidToMax
oChart.DisplayBlanksAs = Graph.XlDisplayBlanksAs.xlInterpolated
oChart.ChartArea.Font.Italic = True
oChart.ChartArea.Interior.Color = RGB(128, 128, 128)
End Sub

End Module

NOTE: the FileImport did not accept an .NET DataSet, that is why I suggest
you transfer your data into Excel Worksheet first.
Here the information for FileImport Method.

Imports a specified file or range, or an entire sheet of data.
expression.FileImport(FileName, Password, ImportRange, WorksheetName,
OverwriteCells)
expression Required. An expression that returns an Application object.
FileName Required String. The file that contains the data to be imported.
Password Optional Variant. The password for the file to be imported, if the
file is password protected.
ImportRange Optional Variant. The range of cells to be imported, if the
file to be imported is a Microsoft Excel worksheet or workbook. If this
argument is omitted, the complete contents of the worksheet are imported.
WorksheetName Optional Variant. The name of the worksheet to be imported,
if the file to be imported is a Microsoft Excel workbook.
OverwriteCells Optional Variant. True to specify that the user be notified
before imported data overwrites existing data on the specified datasheet.
The default value is True.
Example
This example imports data from the range A2:D5 on the worksheet named
"MySheet" in the Microsoft Excel workbook named "mynums.xls."
With myChart.Application
.FileImport FileName:="C:\mynums.xls", _
ImportRange:="A2:D5", WorksheetName:="MySheet", _
OverwriteCells:=False
End With

Please have a try and let me know the result.



Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
 
v-phuang





PostPosted: Thu Oct 05 22:59:41 CDT 2006 Top

Visual Basic [VB] >> MS Word Chart filled with data - URGENT PLEASE Hi,

In addition, here is the document for MS GRAPH Object Modal.
<Program Files>\Microsoft Office\OFFICE11\1033\VBAGR10.CHM

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
 
v-phuang





PostPosted: Wed Oct 11 05:10:59 CDT 2006 Top

Visual Basic [VB] >> MS Word Chart filled with data - URGENT PLEASE Hi,

I am posting to check how the thing is going on.
If you still have any concern on this issue, please feel free to let me
know.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
 
vbnetdev





PostPosted: Tue Nov 14 20:03:02 CST 2006 Top

Visual Basic [VB] >> MS Word Chart filled with data - URGENT PLEASE I ended up filling the sheet with data first like you mentioned. I apologize
for my late response as I had not known you posted.

Thanks again,
Kelly






> Hi,
>
> I am posting to check how the thing is going on.
> If you still have any concern on this issue, please feel free to let me
> know.
>
> Best regards,
>
> Peter Huang
>
> Microsoft Online Community Support
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>