S
scamper
I'm trying to write a VBA script to produce an XY Scatter chatter chart
based on data I'm retrieving from a database.
The main problem I have is to do with setting the series and the data
for the chart. I've found lots of VBA examples of how to do it in
Excel but they don't seem to work in Word.
The code I have so far is:
Dim CurrentChart As Object
Dim oShape As Word.Shape
Dim oGraphChart As Graph.chart
Set oShape =
ActiveDocument.Shapes.AddOLEObject(ClassType:="MSGraph.Chart", FileName
_
:="", LinkToFile:=False, DisplayAsIcon:=False)
Set oGraphChart = oShape.OLEFormat.Object
With oGraphChart
.ChartType = xlXYScatter
.HasAxis(xlCategory, xlPrimary) = False
.HasAxis(xlValue, xlPrimary) = False
.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
.SeriesCollection(1).Points(1).HasDataLabel = True
.SeriesCollection(1).Points(1).DataLabel.Text = "RG24 7AS"
.SeriesCollection(1).XValues = "=4550"
.SeriesCollection(1).Values = "=3120"
.HasLegend = False
.HasDataTable = False
End With
I get an error when setting the XValues.
Has anyone got any example for doing this using Word alone that I can
have a look at?
Regards
Shaun
based on data I'm retrieving from a database.
The main problem I have is to do with setting the series and the data
for the chart. I've found lots of VBA examples of how to do it in
Excel but they don't seem to work in Word.
The code I have so far is:
Dim CurrentChart As Object
Dim oShape As Word.Shape
Dim oGraphChart As Graph.chart
Set oShape =
ActiveDocument.Shapes.AddOLEObject(ClassType:="MSGraph.Chart", FileName
_
:="", LinkToFile:=False, DisplayAsIcon:=False)
Set oGraphChart = oShape.OLEFormat.Object
With oGraphChart
.ChartType = xlXYScatter
.HasAxis(xlCategory, xlPrimary) = False
.HasAxis(xlValue, xlPrimary) = False
.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
.SeriesCollection(1).Points(1).HasDataLabel = True
.SeriesCollection(1).Points(1).DataLabel.Text = "RG24 7AS"
.SeriesCollection(1).XValues = "=4550"
.SeriesCollection(1).Values = "=3120"
.HasLegend = False
.HasDataTable = False
End With
I get an error when setting the XValues.
Has anyone got any example for doing this using Word alone that I can
have a look at?
Regards
Shaun