Hello there,
I would like to generate a radar chart in ms word document using VBA and data reference would be from ms access, here is the code which works well when I put the code in ms word macro and it generates the radar chart, however if I put same code in ms access code behind button it generates series chart. also in ms access I am adding reference of microsoft word 14.0 object library to make the reference of the word graph.
I really dont understand why in word it works well but in ms access it generates series chart instead. also in when I generate the chart from acccess it adds series 3 adding to item 1 and item2, series 3 is not stated anywhere in ms access vba programming.
Please advise. my intention is to generate radar chart in ms word document wherein data point would be from access, the code below is just illustrative. once this works I would bind the data from ms access itself.
Code:
Private Sub Command0_Click()
Dim iShp As InlineShape, wb As Object, ws As Object
Set wdapp = CreateObject("Word.Application")
wdapp.Visible = True
Set wddoc = wdapp.Documents.Add
With wddoc 'xlLineMarkers,xlRadarFilled
Set iShp = .InlineShapes.AddChart(Type:=xlRadarMarkers, Range:=.Range.Characters.Last)
With iShp
Set wb = .Chart.ChartData.Workbook
Set ws = wb.Worksheets(1)
With ws
.Range("A2:A7").NumberFormat = "General"
.Range("A2").Value = 1
.Range("A3").Value = 2
.Range("A4").Value = 3
.Range("A5").Value = 4
.Range("A6").Value = 5
.Range("A7").Value = 6
.Range("B1").Value = "Item 1"
.Range("B2").Value = 100
.Range("B3").Value = 120
.Range("B4").Value = 140
.Range("B5").Value = 160
.Range("B6").Value = 180
.Range("B7").Value = 200
.Range("C1").Value = "Item 2"
.Range("C2").Value = 210
.Range("C3").Value = 190
.Range("C4").Value = 170
.Range("C5").Value = 150
.Range("C6").Value = 130
.Range("C7").Value = 110
End With
.Chart.Refresh
wb.Application.Quit
End With
End With
End Sub