Hello,
I've been coding in Access VBA to create an Excel Graph and it was good.
Until I got this error:
The error occured in this line:
Please check the rest of the code below.
Can somebody explain to me why there's an error?
I'm stuck now.
Help is really, greatly appreciated.
I've been coding in Access VBA to create an Excel Graph and it was good.
Until I got this error:
1004 Unable to set the Values property of the Series class
The error occured in this line:
Code:
.SeriesCollection(4).Values = oSheet.Range("A7").Resize(1, 3)
Please check the rest of the code below.
Can somebody explain to me why there's an error?

Code:
Dim oXL As Excel.Application ' Excel application
Dim oBook As Excel.Workbook ' Excel workbook
Dim oSheet As Excel.Worksheet ' Excel Worksheet
Dim oChart As Excel.Chart ' Excel Chart
On Error GoTo Err_CreateChart
'Start Excel and create a new workbook
Set oXL = CreateObject("Excel.application")
Set oBook = oXL.Workbooks.Add
Set oSheet = oBook.Worksheets.Item(1)
oSheet.Range("A1").Resize(7, 3).Value = aTemp
oSheet.Name = "Chart_Data"
Set oChart = oXL.Charts.Add
With oChart
.SetSourceData Source:=oSheet.Range("A1").Resize(7, 4), PlotBy:=xlColumns
.ApplyCustomType ChartType:=xlBuiltIn, TypeName:="Line - Column on 2 Axes"
.SeriesCollection(1).XValues = oSheet.Range("A1").Resize(1, 3)
.SeriesCollection(1).Values = oSheet.Range("A4").Resize(1, 3)
.SeriesCollection(1).Name = "Plan"
.SeriesCollection(2).Values = oSheet.Range("A6").Resize(1, 3)
.SeriesCollection(2).Name = "Actual"
.SeriesCollection(3).Values = oSheet.Range("A5").Resize(1, 3)
.SeriesCollection(3).Name = "Accu. Plan"
[COLOR=red].SeriesCollection(4).Values = oSheet.Range("A7").Resize(1, 3) '<-- ERROR occurs here...what's the reason?[/COLOR]
.SeriesCollection(4).Name = "Accu. Actual"
.Location Where:=xlLocationAsNewSheet, Name:="Chart_MD"
.HasTitle = True
.Axes(xlCategory, xlSecondary).HasTitle = True
.Axes(xlCategory, xlSecondary).AxisTitle.Characters.Text = "Accumulated"
.ChartTitle.Characters.Text = "Char Title"
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "AAA"
.Axes(xlValue, xlSecondary).HasTitle = True
.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Accumulated AAA"
.HasLegend = False
.HasDataTable = True
.DataTable.ShowLegendKey = True
' Unselect the ActiveChart
.Deselect
End With
oXL.ActiveWindow.Zoom = 85
' Make Excel Visible:
oXL.Visible = True
oXL.UserControl = True
Exit_CreateChart:
'clean-up
Set oXL = Nothing: Set oChart = Nothing: Set oSheet = Nothing: Set oBook = Nothing
Exit Sub
Err_CreateChart:
MsgBox CStr(Err) & " " & Err.Description
Resume Exit_CreateChart
I'm stuck now.

Help is really, greatly appreciated.