改变Word文档中chart的legendkey的颜色,分不够再加!!!

sky-defender 2009-11-24 11:09:28
VBA里面是这么实现的

Sub Macro18()
'

'

'
ActiveChart.Legend.Select
ActiveChart.Legend.LegendEntries(4).LegendKey.Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
With Selection.Interior
.ColorIndex = 44
.Pattern = xlSolid
End With
End Sub


但是在c#里,找不到合适的代码来实现
((LegendKey)objChart.Legend.LegendEntries(1)).Interior.ColorIndex = 3;

用这句的话,程序老报错,说无法把object转换为legendkey


另外:
柱状图显示了value之后,如何调整value字体的大小?

ActiveWindow.Visible = False
Windows("Book1.xls").Activate
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.SeriesCollection(1).DataLabels.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "ËÎÌå"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.SeriesCollection(2).DataLabels.Select
Selection.AutoScaleFont = True
With Selection.Font
.Name = "ËÎÌå"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
End Sub

...全文
73 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sky-defender 2009-11-24
  • 打赏
  • 举报
回复
没人回
自己顶
达人快来

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧