Não é mais possível fazer postagens ou usar assinaturas novas da Usenet nos Grupos do Google. O conteúdo histórico continua disponível.
Dismiss

secondary axes for chart type "lines on 2 axes"

3 visualizações
Pular para a primeira mensagem não lida

Steve Stowers

não lida,
25 de out. de 2001, 13:11:0125/10/2001
para
Hello,
 
I am trying to create an addin to create a chart of type "lines on 2 axes"
as shown below.  The problem however is that I continually get an error
message "Method 'Axes' of object '_Chart' failed, run-time error 1004.
This occurs when trying to set the titles for the secondary axes.  I
assume this should work since the macro created it but unfortunately it
does not.  Highlighted below is where the error occurs:
  .Axes(xlCategory, xlSecondary).HasTitle = True
  .Axes(xlCategory, xlSecondary).AxisTitle.Characters.Text =
"Special Cause Flag"


Any comments would be greatly appreciated.

THanks,

Steve Stowers

sample code:

    public co as chartobject
    Set co = Worksheets("sheet1").ChartObjects.Add(0, 0, 500, 300)

    co.Chart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
      "Lines on 2 Axes"

    co.Chart.SetSourceData Source:=Sheets("Sheet1").Range("A1"),
PlotBy:= _
        xlColumns

    co.Chart.SeriesCollection.NewSeries
    co.Chart.SeriesCollection(1).XValues = "='test plot.xls'!X_ValueC"
    co.Chart.SeriesCollection(1).Values = "='test plot.xls'!IUCLC"
    co.Chart.SeriesCollection(1).Name = "=""Upper Process Limit"""

    co.Chart.SeriesCollection.NewSeries
    co.Chart.SeriesCollection(2).XValues = "='test plot.xls'!X_ValueC"
    co.Chart.SeriesCollection(2).Values = "='test plot.xls'!ILCLC"
    co.Chart.SeriesCollection(2).Name = "=""Lower Process Limit"""

    co.Chart.Location Where:=xlLocationAsObject, Name:="Sheet1"

    With ActiveChart
        .HasTitle = False
        .Axes(xlCategory, xlPrimary).HasTitle = True
        .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text =
"Period"
        .Axes(xlValue, xlPrimary).HasTitle = True
        .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text =
"Individual Value"
        .ChartArea.Interior.ColorIndex = xlNone
    End With

********  problem section
    With ActiveChart
        .HasTitle = False
        .Axes(xlCategory, xlSecondary).HasTitle = True
        .Axes(xlCategory, xlSecondary).AxisTitle.Characters.Text =
"Special Cause Flag"
        .Axes(xlValue, xlSecondary).HasTitle = True
        .Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Initial
Value"
   End With

Jon Peltier

não lida,
29 de out. de 2001, 21:32:3729/10/2001
para
Steve -

Aha! After falling down on this one, I figured it out.

When Excel creates the chart, it knows what's on its own mind. So it
automatically puts Series 2 onto the second set of axes. When you rerun the
macro, however, Excel has no idea what YOU wanted, so it puts both series
onto the first axes. Axes(xlYada, xlSecondary).HasTitle is meaningless,
because you have no Axes(xlYada, xlSecondary) yet. You need to insert this
before the .HasAxis statement:

.SeriesCollection(2).AxisGroup = 2

Then Excel gets the hint, and knows you really really want two Y axes,
despite selecting TypeName:="Lines on 2 Axes".

Since you need the line to assign series 2 to the secondary axes, you might
as well just use

.ChartType = xlLineMarkers

instead of

.ChartType:=xlBuiltIn, TypeName:="Lines on 2 Axes"

I was going to suggest this even before trying to record and run the same
macro you had trouble with.

- Jon
_______

In article <FIXB7.6006$nj.9...@typhoon.austin.rr.com>, Steve Stowers said...
>
>This is a multi-part message in MIME format.
>
>------=_NextPart_000_0038_01C15D4E.1F4B8600
>Content-Type: text/plain;
> charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
>Hello,
>
>I am trying to create an addin to create a chart of type "lines on 2 =


>axes"
>as shown below. The problem however is that I continually get an error
>message "Method 'Axes' of object '_Chart' failed, run-time error 1004.
>This occurs when trying to set the titles for the secondary axes. I
>assume this should work since the macro created it but unfortunately it
>does not. Highlighted below is where the error occurs:
>

> .Axes(xlCategory, xlSecondary).HasTitle =3D True
> .Axes(xlCategory, xlSecondary).AxisTitle.Characters.Text =3D


>"Special Cause Flag"
>
>
>Any comments would be greatly appreciated.
>
>THanks,
>
>Steve Stowers
>
>
>sample code:
>
> public co as chartobject

> Set co =3D Worksheets("sheet1").ChartObjects.Add(0, 0, 500, 300)
>
> co.Chart.ApplyCustomType ChartType:=3DxlBuiltIn, TypeName:=3D _
> "Lines on 2 Axes"
>
> co.Chart.SetSourceData Source:=3DSheets("Sheet1").Range("A1"),
>PlotBy:=3D _
> xlColumns
>
> co.Chart.SeriesCollection.NewSeries
> co.Chart.SeriesCollection(1).XValues =3D "=3D'test =
>plot.xls'!X_ValueC"
> co.Chart.SeriesCollection(1).Values =3D "=3D'test plot.xls'!IUCLC"
> co.Chart.SeriesCollection(1).Name =3D "=3D""Upper Process Limit"""
>
> co.Chart.SeriesCollection.NewSeries
> co.Chart.SeriesCollection(2).XValues =3D "=3D'test =
>plot.xls'!X_ValueC"
> co.Chart.SeriesCollection(2).Values =3D "=3D'test plot.xls'!ILCLC"
> co.Chart.SeriesCollection(2).Name =3D "=3D""Lower Process Limit"""
>
> co.Chart.Location Where:=3DxlLocationAsObject, Name:=3D"Sheet1"
>
> With ActiveChart
> .HasTitle =3D False
> .Axes(xlCategory, xlPrimary).HasTitle =3D True
> .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text =3D
>"Period"
> .Axes(xlValue, xlPrimary).HasTitle =3D True
> .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text =3D
>"Individual Value"
> .ChartArea.Interior.ColorIndex =3D xlNone


> End With
>
>******** problem section
> With ActiveChart

> .HasTitle =3D False
> .Axes(xlCategory, xlSecondary).HasTitle =3D True
> .Axes(xlCategory, xlSecondary).AxisTitle.Characters.Text =3D
>"Special Cause Flag"
> .Axes(xlValue, xlSecondary).HasTitle =3D True
> .Axes(xlValue, xlSecondary).AxisTitle.Characters.Text =3D =
>"Initial
>Value"
> End With
>
>
>------=_NextPart_000_0038_01C15D4E.1F4B8600
>Content-Type: text/html;
> charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
><HTML><HEAD>
><META http-equiv=3DContent-Type content=3D"text/html; =
>charset=3Diso-8859-1">
><META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
><STYLE></STYLE>
></HEAD>
><BODY bgColor=3D#ffffff>
><DIV><FONT face=3DArial size=3D2>
><DIV><FONT face=3DArial size=3D2>Hello,</FONT></DIV>
><DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
><DIV>I am trying to create an addin&nbsp;to create a chart of type =
>"lines on 2=20
>axes"<BR>as shown below.&nbsp; The problem however is that I continually =
>get an=20
>error<BR>message "Method 'Axes' of object '_Chart' failed, run-time =
>error=20
>1004.<BR>This occurs when trying to set the titles for the secondary =
>axes.&nbsp;=20
>I<BR>assume this should work since the macro created it but =
>unfortunately=20
>it<BR>does not.&nbsp; Highlighted below is where the error =
>occurs:<BR></DIV>
><DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman"=20
>size=3D3>&nbsp;&nbsp;<FONT color=3D#ff0000>.Axes(xlCategory, =
>xlSecondary).HasTitle =3D=20
>True<BR>&nbsp; .Axes(xlCategory, xlSecondary).AxisTitle.Characters.Text=20
>=3D<BR>"Special Cause Flag"</FONT></FONT><BR></FONT></DIV><FONT =
>face=3DArial=20
>size=3D2></FONT>
><DIV><BR>Any comments would be greatly =
>appreciated.<BR><BR>THanks,<BR><BR>Steve=20
>Stowers<BR><BR></DIV>
><DIV><FONT color=3D#0000ff><FONT face=3DArial size=3D2>sample=20
>code:</FONT><BR><BR>&nbsp;&nbsp;&nbsp; public co as=20
>chartobject<BR>&nbsp;&nbsp;&nbsp; Set co =3D=20
>Worksheets("sheet1").ChartObjects.Add(0, 0, 500, =
>300)<BR><BR>&nbsp;&nbsp;&nbsp;=20
>co.Chart.ApplyCustomType ChartType:=3DxlBuiltIn, TypeName:=3D=20
>_<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "Lines on 2 =
>Axes"<BR><BR>&nbsp;&nbsp;&nbsp;=20
>co.Chart.SetSourceData =
>Source:=3DSheets("Sheet1").Range("A1"),<BR>PlotBy:=3D=20
>_<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
>xlColumns<BR><BR>&nbsp;&nbsp;&nbsp;=20
>co.Chart.SeriesCollection.NewSeries<BR>&nbsp;&nbsp;&nbsp;=20
>co.Chart.SeriesCollection(1).XValues =3D "=3D'test=20
>plot.xls'!X_ValueC"<BR>&nbsp;&nbsp;&nbsp; =
>co.Chart.SeriesCollection(1).Values =3D=20
>"=3D'test plot.xls'!IUCLC"<BR>&nbsp;&nbsp;&nbsp; =
>co.Chart.SeriesCollection(1).Name=20
>=3D "=3D""Upper Process Limit"""<BR><BR>&nbsp;&nbsp;&nbsp;=20
>co.Chart.SeriesCollection.NewSeries<BR>&nbsp;&nbsp;&nbsp;=20
>co.Chart.SeriesCollection(2).XValues =3D "=3D'test=20
>plot.xls'!X_ValueC"<BR>&nbsp;&nbsp;&nbsp; =
>co.Chart.SeriesCollection(2).Values =3D=20
>"=3D'test plot.xls'!ILCLC"<BR>&nbsp;&nbsp;&nbsp; =
>co.Chart.SeriesCollection(2).Name=20
>=3D "=3D""Lower Process Limit"""<BR><BR>&nbsp;&nbsp;&nbsp; =
>co.Chart.Location=20
>Where:=3DxlLocationAsObject, Name:=3D"Sheet1"<BR><BR>&nbsp;&nbsp;&nbsp; =
>With=20
>ActiveChart<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .HasTitle =3D=20
>False<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Axes(xlCategory,=20
>xlPrimary).HasTitle =3D =
>True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
>.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text=20
>=3D<BR>"Period"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
>.Axes(xlValue,=20
>xlPrimary).HasTitle =3D =
>True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
>.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text =3D<BR>"Individual=20
>Value"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
>.ChartArea.Interior.ColorIndex =3D xlNone<BR>&nbsp;&nbsp;&nbsp; End=20
>With<BR><BR></FONT><FONT color=3D#ff0000>********&nbsp; problem=20
>section<BR>&nbsp;&nbsp;&nbsp; With=20
>ActiveChart<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .HasTitle =3D=20
>False<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Axes(xlCategory,=20
>xlSecondary).HasTitle =3D =
>True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
>.Axes(xlCategory, xlSecondary).AxisTitle.Characters.Text =3D<BR>"Special =
>Cause=20
>Flag"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Axes(xlValue,=20
>xlSecondary).HasTitle =3D =
>True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
>.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text =3D=20
>"Initial<BR>Value"<BR>&nbsp;&nbsp; End=20
>With<BR></FONT></DIV></FONT></DIV></BODY></HTML>
>
>------=_NextPart_000_0038_01C15D4E.1F4B8600--
>

0 nova mensagem