误差线在图表中不可见

Error bars not visible in chart

我正在尝试在 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

请帮忙。

删除这两行:

.HasErrorBars = True
.ErrorBars.Select

终于有了解决办法,虽然有点粗糙。

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

        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