在 VBA 中操作 excel 2007 图表网格线

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1261306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 10:40:56  来源:igfitidea点击:

Manipulating excel 2007 chart grid lines in VBA

vb.netexcelvbavstoexcel-2007

提问by

Using Excel 2007, is it possible to change the transparency of chart grid lines using VBA or VB.NET?

使用 Excel 2007,是否可以使用 VBA 或 VB.NET 更改图表网格线的透明度?

I have the following code, which throws an exception on the last line:

我有以下代码,它在最后一行引发异常:

Dim axis As Excel.Axis = chart.Axes(Excel.XlAxisType.xlCategory)
axis.HasMajorGridlines = True
axis.MajorGridlines.Border.Color = Color.Gray.ToArgb
axis.MajorGridlines.Border.LineStyle = Excel.XlLineStyle.xlContinuous
axis.MajorGridlines.Format.Fill.Transparency = 0.8

( Of course, this code is in VB.NET )

(当然,这段代码在 VB.NET 中)

Thanks!

谢谢!

回答by

In the last line of your code, I think it should be

在你的代码的最后一行,我认为应该是

axis.MajorGridlines.Format.Line.Transparency = 0.8

That works for me and adjusts the transparency of the vertical gridlines.

这对我有用并调整垂直网格线的透明度。