Hi all,
I have written some VBA in Access that is controlling an Excel spreadsheet I have created using OLE automation. Everything works fine, except I am having trouble getting my VBA to set the background picture of a chart on my spreadsheet. Here is the code from the subroutine that is adding the background to the chart:
I have written some VBA in Access that is controlling an Excel spreadsheet I have created using OLE automation. Everything works fine, except I am having trouble getting my VBA to set the background picture of a chart on my spreadsheet. Here is the code from the subroutine that is adding the background to the chart:
Code:
Private Sub fillchart(ByVal rngDataSource As range)
Dim iDataRowsCt As Long
Dim iDataColsCt As Integer
Dim iSrsIx As Integer
Dim srsNew As Series
With rngDataSource
iDataRowsCt = .Rows.Count
iDataColsCt = .Columns.Count
End With
With chtCTQChart
.ChartType = xlXYScatter
For iSrsIx = 2 To iDataRowsCt
Set srsNew = .SeriesCollection.NewSeries
With srsNew
.Name = rngDataSource.Cells(iSrsIx, 1)
.Values = rngDataSource.Cells(iSrsIx, 2)
.XValues = rngDataSource(iSrsIx, 3)
End With
Next iSrsIx
With .Axes(xlValue)
.MaximumScale = 5
.MinimumScale = 0
End With
.SetBackgroundPicture FileName:="c:\chartbackground.gif"
End With
End Sub