Microsoft Office Tutorials and References
In Depth Information
Mail Merge: Merging with a Chart
' * * * * *¶
Sub ProcessPieChart(ByRef ds As Graph.DataSheet, _¶
tbl As Word.Table, ByVal nrDataCols As Long)¶
'Variable declaration¶
Dim rwData As Word.Row¶
Dim datavalue As Double¶
Dim rwLabels As Word.Row¶
Dim colcounter As Long, i As Long¶
colcounter = 1¶
'Data series in rows!¶
ds.Application.PlotBy = xlRows¶
'First column contains record ID¶
'Following columns contain data¶
'One row per record¶
'First row contains Legend labels¶
Set rwLabels = tbl.Rows(1)¶
Set rwData = tbl.Rows(recordIndex)¶
'Loop through the data columns¶
For i = 2 To nrDataCols¶
With ds¶
datavalue = CDbl(Val( _¶
TrimCellText(rwData.Cells(i).Range.Text)))¶
'Don't carry over 0 values¶
'If 0 values should be used¶
'comment out If and End If lines¶
If datavalue > 0 Then¶
colcounter = colcounter + 1¶
'carry over the column header¶
.Cells(1, colcounter).Value _¶
= TrimCellText(rwLabels.Cells(i).Range.Text)¶
'and the data to the data sheet¶
.Cells(2, colcounter).Value _¶
= datavalue¶
End If¶
End With¶
Next i¶
End Sub¶
' * * * * *¶
Sub ProcessOtherChart(ByRef ds As Graph.DataSheet, _¶
tbl As Word.Table, ByVal nrDataCols As Long)¶
'Variable declaration¶
Dim rwData As Word.Row¶
Dim rwLabels As Word.Row¶
Dim rowCounter As Long¶
Dim totalRows As Long¶
Dim ID As String¶
Dim datavalue As Double¶
Dim colcounter As Long, i As Long¶
colcounter = 1¶
rowCounter = 1¶
totalRows = tbl.Rows.Count¶
Wrd
Search JabSto ::




Custom Search