2012-01-31 6 views
2

私は1つのプロジェクトに取り組んでいます。私はチャートがx軸かy軸かどうかをチェックしたいと思います。そうでない場合は追加してください。 x軸やy軸にタイトルがあるかどうかをチェックしたいと思っています。そうでなければ、タイトルを提供する。vbaを使用してパワーポイントのグラフに軸を追加しますか?

私は、x軸またはy軸にタイトルがあるかどうかをチェックする1つのコードを書いています。しかし、それでは、タイトルを追加する方法はありますか?

この

は私も割り当てない場合は軸を追加したい上記のコードで

Dim oSld As Slide 
Dim oShp As Shape 
Dim oShapes As Shapes 
Dim yaxes as Boolean 
Dim xaxes as Boolean 

On Error GoTo Errorhandler: 
For Each oSld In ActivePresentation.Slides 

Set oShapes = oSld.Shapes 
For Each oShp In oShapes 
    If oShp.HasChart Then 

       If oShp.HasChart Then 

        yaxes = oShp.Chart.Axes(xlValue, xlPrimary).HasTitle 
        xaxes = oShp.Chart.Axes(xlCategory).HasTitle 

        'check x axies have title 
        If xaxes <> True Then 
        ' Add title 

        End If 
        'check y axies have title 
        If yaxes <> True Then 
        ' Add title 

        End If 
       End If 
    End If 
Next oShp 
Next 

ので、軸のタイトルを見つけるためのコードです。

ありがとうございました。このような

答えて

1

何かが

  1. 彼らは

    Dim oSld As Slide 
    Dim oShp As Shape 
    Dim oShapes As Shapes 
    For Each oSld In ActivePresentation.Slides 
        Set oShapes = oSld.Shapes 
        For Each oShp In oShapes 
         If oShp.HasChart Then 
          If oShp.HasChart Then 
           With oShp.Chart 
            If Not .HasAxis(xlValue) Then .HasAxis(xlValue) = True 
            If Not .HasAxis(xlCategory) Then .HasAxis(xlCategory) = True 
            If Not .Axes(xlCategory).HasTitle Then .Axes(xlCategory).HasTitle = True 
            If Len(.Axes(xlCategory).AxisTitle.Text) = 0 Then .Axes(xlCategory).AxisTitle.Text = "I'm X" 
            If Not .Axes(xlValue).HasTitle Then .Axes(xlValue).HasTitle = True 
            If Len(.Axes(xlValue).AxisTitle.Text) = 0 Then .Axes(xlValue).AxisTitle.Text = "I'm Y" 
           End With 
          End If 
         End If 
        Next oShp 
    Next oSld 
    
+0

おかげbrettdj存在しない軸/タイトルを追加そのまま既存の軸および/またはタイトルを残します。なぜ私はAxesの他の特性を知っていないのですか? –

関連する問題