P
peaton
I am trying to add a chart with VB6. I am getting similar errors on
all line from the 'HasTitle' line.
eg "Method 'HasTitle' of object '_Chart' failed"
I Cannot work out what is wrong I initially recorded the code and
ammended it.
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlChart As Excel.Chart
With xlApp.Workbooks(xlBook.Name).Worksheets(xlSheet.Name)
Set xlChart = xlApp.Charts.Add
xlChart.ChartType = xlLineMarkers
xlChart.SetSourceData Source:=.Range(.Cells(lHeaderRow + 1, lUsageCol),
..Cells(lRowCnt - 1, lUsageCol)), _
PlotBy:=xlColumns
xlChart.SeriesCollection(1).XValues = _
.Range(.Cells(lHeaderRow + 1, lDateCol), .Cells(lRowCnt - 1,
lDateCol))
xlChart.Location Where:=xlLocationAsObject, Name:=xlSheet.Name
xlChart.HasTitle = True
xlChart.ChartTitle.Characters.Text = "Disk Space History: " &
rsDrives.Fields("DrivePath")
xlChart.Axes(xlCategory, xlPrimary).HasTitle = True
xlChart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"
xlChart.Axes(xlValue, xlPrimary).HasTitle = True
xlChart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "% Usage"
xlChart.HasAxis(xlCategory, xlPrimary) = True
xlChart.HasAxis(xlValue, xlPrimary) = True
xlChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
xlChart.HasLegend = False
End With
Thanks in advance for your help .... Paul
all line from the 'HasTitle' line.
eg "Method 'HasTitle' of object '_Chart' failed"
I Cannot work out what is wrong I initially recorded the code and
ammended it.
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlChart As Excel.Chart
With xlApp.Workbooks(xlBook.Name).Worksheets(xlSheet.Name)
Set xlChart = xlApp.Charts.Add
xlChart.ChartType = xlLineMarkers
xlChart.SetSourceData Source:=.Range(.Cells(lHeaderRow + 1, lUsageCol),
..Cells(lRowCnt - 1, lUsageCol)), _
PlotBy:=xlColumns
xlChart.SeriesCollection(1).XValues = _
.Range(.Cells(lHeaderRow + 1, lDateCol), .Cells(lRowCnt - 1,
lDateCol))
xlChart.Location Where:=xlLocationAsObject, Name:=xlSheet.Name
xlChart.HasTitle = True
xlChart.ChartTitle.Characters.Text = "Disk Space History: " &
rsDrives.Fields("DrivePath")
xlChart.Axes(xlCategory, xlPrimary).HasTitle = True
xlChart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date"
xlChart.Axes(xlValue, xlPrimary).HasTitle = True
xlChart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "% Usage"
xlChart.HasAxis(xlCategory, xlPrimary) = True
xlChart.HasAxis(xlValue, xlPrimary) = True
xlChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
xlChart.HasLegend = False
End With
Thanks in advance for your help .... Paul