尝试编写VBA代码,使三维曲面图中的波段透明和/或半透明。当我录制宏时,手动点击图例,然后是乐队,然后更改其属性Excel 2010记录了以下代码:
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(47).Select
With Selection.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
.Solid
End With
With Selection.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 1
.Solid
End With
但是当我尝试执行时,我收到一条错误消息,指出不支持“Format.Fill”。
我用来改变乐队颜色的代码是:
With Worksheets("Sheet23").ChartObjects(1).Chart.Legend.LegendEntries(BandCount)
.LegendKey.Interior.Color = RGB(Red(BandCount), Green(BandCount), Blue(BandCount))
.LegendKey.Shadow = 1
End With
有谁知道如何修改此代码以控制透明度? 谢谢!
答案 0 :(得分:0)
而不是:
With Selection.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0
.Solid
End With
使用它:
With Selection.LegendKey.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
.Transparency = 0.5 <-- Or whatever value of transparency you want
.Solid
End With
这是基于G North在 this post 中推荐的方法。