0

我正在尝试在 MS Powerpoint 的图表中创建水平和垂直误差线。虽然我可以使用 VBA 设置误差线的参数,但是误差线是不可见的。当我手动检查图表中的误差线设置时,所需的设置就完成了。下面是我正在尝试的代码:

ActivePresentation.Slides(SlideNumb).Shapes(ChartName).Chart.Select
With ActivePresentation.Slides(SlideNumb).Shapes(ChartName).Chart.SeriesCollection(2)
    .HasErrorBars = True
    .ErrorBars.Select
    .ErrorBar Direction:=xlY, Include:=xlErrorBarIncludeBoth, Type:=xlErrorBarTypeCustom, Amount:=100, MinusValues:=100
    .ErrorBar Direction:=xlX, Include:=xlErrorBarIncludeBoth, Type:=xlErrorBarTypeCustom, Amount:=100, MinusValues:=100
End With
With ActivePresentation.Slides(SlideNumb).Shapes(ChartName).Chart.SeriesCollection(2).ErrorBars.Border
    .LineStyle = msoLineSingle   
    .Color = RGB(0, 112, 192)
    .Weight = 1.5
End With 
With ActivePresentation.Slides(SlideNumb).Shapes(ChartName).Chart.SeriesCollection(2).ErrorBars
     .Select
     .Format.Line.Visible = msoTrue
     .Format.Line.Style = msoLineSingle
     .Format.Line.Weight = 1.5
     .Format.Line.ForeColor.RGB = RGB(0, 112, 192)
     .Format.Line.DashStyle = msoLineSysDash
     .EndStyle = xlNoCap
End With

请帮忙。

4

2 回答 2

0

最后,虽然有点粗糙,但有一个解决问题的方法。

在图表中创建了两个相似的系列集合,并在一个上应用了水平误差条图,在第二个上应用了垂直误差条图。以下是代码:

        ActivePresentation.Slides(SlideNumb).Shapes(ChartName).Chart.FullSeriesCollection(2).ErrorBar Direction:=xlY, Include:=xlBoth, Type:=xlFixedValue, Amount:=1000
        With ActivePresentation.Slides(SlideNumb).Shapes(ChartName).Chart.FullSeriesCollection(2).ErrorBars
            .EndStyle = xlCap
            With .Format.Line
                .Visible = msoTrue
                .DashStyle = msoLineDash
                .Weight = 2
                .ForeColor.ObjectThemeColor = msoThemeColorAccent1
            End With
        End With

        ActivePresentation.Slides(SlideNumb).Shapes(ChartName).Chart.FullSeriesCollection(3).ErrorBar Direction:=xlX, Include:=xlBoth, Type:=xlFixedValue, Amount:=1000
        With ActivePresentation.Slides(SlideNumb).Shapes(ChartName).Chart.FullSeriesCollection(3).ErrorBars
            .EndStyle = xlCap
            With .Format.Line
                .Visible = msoTrue
                .DashStyle = msoLineDash
                .Weight = 2
                .ForeColor.ObjectThemeColor = msoThemeColorAccent1
            End With
        End With
于 2016-11-15T16:28:17.793 回答
0

删除这两行:

.HasErrorBars = True
.ErrorBars.Select
于 2016-09-26T14:10:15.090 回答