如何更改图表中的所有字体?

我正试图改变整个图表的字体。 使用Shapes集合logging的macros>形状对象> TextFrame2(包含指定形状的文本格式)> TextRange> Font。

With ActiveSheet.Shapes("Chart 1502").TextFrame2.TextRange.Font .NameComplexScript = "Arial" .NameFarEast = "Arial" .Name = "Arial" End With 

我在文档中检查它,似乎是好方法,但是当我尝试运行此录制的macto时,它会抛出: 运行时错误:'-2147024809(80070057)': input的值超出范围 (我的翻译 – 我已本地化版)。

错误是在这一行(特别是与TextFrame2

 With ActiveSheet.Shapes("Chart 1502").TextFrame2.TextRange.Font 

因为

 set x = ActiveSheet.Shapes("Chart 1502")' is OK 

 set x = ActiveSheet.Shapes("Chart 1502").TextFrame2 'throws Run-Time Error 

试试这个:

 Sub test() Dim x As Shape Set x = ActiveSheet.Shapes("Chart 1502") With x.Chart.ChartArea.Format.TextFrame2.TextRange.Font .NameComplexScript = "Arial" .NameFarEast = "Arial" .Name = "Arial" End With End Sub 

我还build议将ActiveSheet.Shapes("Chart 1502")更改为如下所示: Worksheets("Sheet1").Shapes("Chart 1502")