2016-09-26 54 views
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 

請幫忙。

回答

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 
0

刪除這兩條線:

.HasErrorBars = True 
.ErrorBars.Select 
+0

試過這樣做,但結果相同。設置完成但條形圖不可見。 –

+0

它是什麼類型的圖表?我認爲這一定是XY分散。 –

+0

我正在使用3D氣泡圖。 –