Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel 2000 Chart & VBA: why oh why?!?

Hi everyone. I created a macro with the Record New Macro in Excel to
create a chart "Lines on 2 Axes". When I create the chart by hand, all
goes well, but when I replay the macro it crashes with the error
"Run-time error '1004' Method'Axes' of object'_Chart' failed". Can
anyone help me here? I am completely desperate, I don't know what to
do. I tried Jon Peltier's answer to this
(http://groups.google.com/groups?q=Me...ftngp05&rnum=6)
question but it doesn't seem to work for me.

Here's my code:

Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn,
TypeName:="Line - Column on 2 Axes"
ActiveChart.SetSourceData Source:=Sheets("Tempo Médio de
Espera").Range("A1")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
'ActiveChart.SeriesCollection(1).AxisGroup = 3
ActiveChart.SeriesCollection(1).XValues = "='Tempo Médio de
Espera'!R4C2:R15C2"
ActiveChart.SeriesCollection(1).Values = "='Tempo Médio de
Espera'!R4C4:R15C4"
ActiveChart.SeriesCollection(1).Name = "='Tempo Médio de
Espera'!R3C4"
ActiveChart.SeriesCollection(2).Values = "='Tempo Médio de
Espera'!R4C6:R15C6"
ActiveChart.SeriesCollection(2).Name = "='Tempo Médio de
Espera'!R3C6"
ActiveChart.SeriesCollection(3).Values = "='Tempo Médio de
Espera'!R4C8:R15C8"
ActiveChart.SeriesCollection(3).Name = "='Tempo Médio de
Espera'!R3C8"
ActiveChart.SeriesCollection(4).Values = "='Tempo Médio de
Espera'!R4C3:R15C3"
ActiveChart.SeriesCollection(4).Name = "='Tempo Médio de
Espera'!R3C3"
ActiveChart.SeriesCollection(5).Values = "='Tempo Médio de
Espera'!R4C5:R15C5"
ActiveChart.SeriesCollection(5).Name = "='Tempo Médio de
Espera'!R3C5"
ActiveChart.SeriesCollection(6).Values = "='Tempo Médio de
Espera'!R4C7:R15C7"
ActiveChart.SeriesCollection(6).Name = "='Tempo Médio de
Espera'!R3C7"
ActiveChart.Location Whe=xlLocationAsObject, Name:="Tempo
Médio de Espera"

With ActiveChart
'.SeriesCollection(6).AxisGroup = 2
.HasTitle = True
.ChartTitle.Characters.Text = "Evolução Horária Tempo
Médio de Espera"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text =
"Espaço Tempo Horário"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Nº
Atendimentos"
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = True
.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text =
"Tempo Médio Horário"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom
ActiveChart.HasDataTable = False
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Excel 2000 Chart & VBA: why oh why?!?

Hi,

I can hardly remember, but it could be possible that you have to "select" or
"actiave" the object you would like to change with your VBA code. I think
you can try this if you use the debugging modus. So, you get the error, you
chose debugging, then you go to that chart and click on the axes that should
be edited, go back to debugging and start again the paused makro from where
it stopped. When the makro then works then you need add a line to your code
that will select the axis or whatever.

Have a try

arno

"Run-time error '1004' Method'Axes' of object'_Chart' failed". Can



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Excel 2000 Chart & VBA: why oh why?!?

Hi Rui -

You shouldn't have to select an element to edit it.

You didn't indicate which line threw the error.

I would not have assigned the built in chart type. I would have started
with a column chart, added each series and defined its X and Y range and
name, then if appropriate changed its chart type and the axis it is
assigned to.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______

Rui Pacheco wrote:

Hi everyone. I created a macro with the Record New Macro in Excel to
create a chart "Lines on 2 Axes". When I create the chart by hand, all
goes well, but when I replay the macro it crashes with the error
"Run-time error '1004' Method'Axes' of object'_Chart' failed". Can
anyone help me here? I am completely desperate, I don't know what to
do. I tried Jon Peltier's answer to this
(http://groups.google.com/groups?q=Me...ftngp05&rnum=6)
question but it doesn't seem to work for me.

Here's my code:

Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn,
TypeName:="Line - Column on 2 Axes"
ActiveChart.SetSourceData Source:=Sheets("Tempo Médio de
Espera").Range("A1")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
'ActiveChart.SeriesCollection(1).AxisGroup = 3
ActiveChart.SeriesCollection(1).XValues = "='Tempo Médio de
Espera'!R4C2:R15C2"
ActiveChart.SeriesCollection(1).Values = "='Tempo Médio de
Espera'!R4C4:R15C4"
ActiveChart.SeriesCollection(1).Name = "='Tempo Médio de
Espera'!R3C4"
ActiveChart.SeriesCollection(2).Values = "='Tempo Médio de
Espera'!R4C6:R15C6"
ActiveChart.SeriesCollection(2).Name = "='Tempo Médio de
Espera'!R3C6"
ActiveChart.SeriesCollection(3).Values = "='Tempo Médio de
Espera'!R4C8:R15C8"
ActiveChart.SeriesCollection(3).Name = "='Tempo Médio de
Espera'!R3C8"
ActiveChart.SeriesCollection(4).Values = "='Tempo Médio de
Espera'!R4C3:R15C3"
ActiveChart.SeriesCollection(4).Name = "='Tempo Médio de
Espera'!R3C3"
ActiveChart.SeriesCollection(5).Values = "='Tempo Médio de
Espera'!R4C5:R15C5"
ActiveChart.SeriesCollection(5).Name = "='Tempo Médio de
Espera'!R3C5"
ActiveChart.SeriesCollection(6).Values = "='Tempo Médio de
Espera'!R4C7:R15C7"
ActiveChart.SeriesCollection(6).Name = "='Tempo Médio de
Espera'!R3C7"
ActiveChart.Location Whe=xlLocationAsObject, Name:="Tempo
Médio de Espera"

With ActiveChart
'.SeriesCollection(6).AxisGroup = 2
.HasTitle = True
.ChartTitle.Characters.Text = "Evolução Horária Tempo
Médio de Espera"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text =
"Espaço Tempo Horário"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Nº
Atendimentos"
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = True
.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text =
"Tempo Médio Horário"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom
ActiveChart.HasDataTable = False


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
PROBLEM:How to squeeze 2 Page sized Chart in Excel 2000 & embed in Word 2000 and print from Word to fit one page ??? [email protected] Excel Discussion (Misc queries) 2 September 10th 08 11:07 AM
PROBLEM:How to squeeze 2 Page sized Chart in Excel 2000 & embed in Word 2000 and print from Word to fit one page ??? [email protected] New Users to Excel 2 September 10th 08 11:07 AM
Excel 2000 - Pie Chart # of slices Bob Charts and Charting in Excel 3 October 31st 06 07:15 PM
Chart disappears in Excel 2000 [email protected] Excel Discussion (Misc queries) 0 November 8th 05 04:42 PM
SECOND Y-AXIS IN A BAR CHART, EXCEL 2000?? GEMINI MAN Charts and Charting in Excel 3 April 25th 05 01:55 PM


All times are GMT +1. The time now is 09:35 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"