Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Adding Chart - Methods Fail

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.Na me)

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 Whe=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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Adding Chart - Methods Fail


wrote:
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.Na me)

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 Whe=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


After spending a couple of hours trying to resolve this, 5 mins after
my post I have found a solution:-

moving "xlChart.Location Whe=xlLocationAsObject, Name:=xlSheet.Name"
to be the last line of the code above.

Why? I do not know - maybe after changing the location it must be
referenced in a different way?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding line chart w/ 2nd axis to stacked bar chart Greg Yedinak Charts and Charting in Excel 1 January 12th 09 10:51 PM
Why would chart fail to update? Janie Charts and Charting in Excel 2 November 19th 08 04:01 PM
Collection methods Christopher Benson-Manica Excel Programming 4 December 9th 04 06:22 PM
3 possible methods for adding value to a combobox Todd Huttenstine[_3_] Excel Programming 3 January 25th 04 01:16 AM
Certain methods do not work Rohit Thomas Excel Programming 4 July 9th 03 06:36 PM


All times are GMT +1. The time now is 02:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"