Microsoft Office Tutorials and References
In Depth Information
Mail Merge: Merging with a Chart
' * * * * *¶
Sub EditChart(rng As Word.Range, _¶
DataDoc As Word.Document)¶
'Variable declaration¶
Dim of As Word.OLEFormat¶
Dim oChart As Graph.Chart¶
Dim oDataSheet As Graph.DataSheet¶
Dim tbl As Word.Table¶
Dim chartType As Long¶
Set tbl = DataDoc.Tables(1)¶
'Activate the MS Graph object in the¶
'main merge document¶
Set of = rng.InlineShapes(1).OLEFormat¶
of.DoVerb wdOLEVerbInPlaceActivate¶
'Pick up the chart for automation¶
Set oChart = of.Object¶
'Is chart a pie chart or not?¶
chartType = oChart.chartType¶
'Data sheet required¶
Set oDataSheet = oChart.Application.DataSheet¶
oChart.DisplayBlanksAs = xlNotPlotted¶
FillDataSheet oDataSheet, tbl, chartType¶
'Finish with the chart¶
oChart.Application.Update¶
oChart.Application.Quit¶
DoEvents¶
Set oChart = Nothing¶
End Sub¶
' * * * * *¶
Sub FillDataSheet(ByRef ds As Graph.DataSheet, _¶
tbl As Word.Table, chartType As Long)¶
'Variable declaration¶
Dim nrDataCols As Long¶
recordIndex = recordIndex + 1¶
nrDataCols = tbl.Columns.Count¶
'Delete all entries in the datasheet¶
ds.Cells.ClearContents¶
If chartType = xlPie Then¶
ProcessPieChart ds, tbl, nrDataCols¶
Else¶
ProcessOtherChart ds, tbl, nrDataCols¶
End If¶
DoEvents¶
End Sub¶
Wrd
Search JabSto ::




Custom Search