vba 如何更改图表轴的字体属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27028681/
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-12 05:18:59  来源:igfitidea点击:

How to change font properties of chart axes

excelvbaexcel-vbaexcel-2010

提问by Greg Lovern

How do I change the font properties of chart axes in Excel 2007 & 2010?

如何更改 Excel 2007 和 2010 中图表轴的字体属性?

NOT the axis title; that one's easy. I'm asking about the font of the axis itelf.

不是轴标题;那个很容易。我问的是轴 itelf 的字体。

It records equivalent to this in Excel 2010:

它在 Excel 2010 中的记录与此等效:

shEditSizeScales.ChartObjects("MyChart").Chart.Axes(xlCategory).Format.TextFrame2.TextRange.Font.Size=12

But I get an error on that, and I don't see anything past TextFrame2 in the Watch pane.

但是我得到了一个错误,在 Watch 窗格中我没有看到任何超过 TextFrame2 的内容。

Even if I step through the recorded code, it gives me the same error.

即使我单步执行记录的代码,它也会给我同样的错误。

I've looked through the object model and I don't see it.

我已经查看了对象模型,但没有看到它。

How is it done?

它是如何完成的?

采纳答案by ZAT

Use this:

用这个:

With ActiveChart.Axes(xlCategory).TickLabels.Font
        '.Bold = msoTrue
        .Size = 18
End With

Source: MS Ref link

来源:MS 参考链接