如何告诉 Axis 有某种字体?
这就是我到目前为止所得到的。 最后五行是录制的宏,不起作用。 Excel 以黄色突出显示“Selection.Format.TextFrame2.TextRange.Font”行。
With objChart.Chart
.ChartArea.AutoScaleFont = False
.ChartType = xlColumnClustered
.HasLegend = False
.HasTitle = False
.SetElement (msoElementChartTitleNone)
.SetElement (msoElementPrimaryValueAxisNone)
.SetElement (msoElementPrimaryValueGridLinesNone)
.HasAxis(xlCategory) = True
' With .Axis(xlCategory).Select
' Selection.Format.TextFrame2.TextRange.Font
' .BaselineOffset = 0
' .Name = "Arial"
' End With
这是录制的宏:
Sub Macro_1()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.FullSeriesCollection(1).Select
With ActiveChart.Axes(xlCategory).Select
With Selection.Format.TextFrame2.TextRange.Font
.BaselineOffset = 0
.Name = "Times"
.Size = 12
End With
End With
End Sub
谢谢!
如果您在下面的最后一行代码上打断并在
ax
上放置一个监视,您可以运行代码,然后在“监视”窗格中检查 ax
的各种属性。我就是这样发现的ax.TickLabels.Font.Name
...
Sub Macro_1()
Dim cht As Chart, ax As Axis
Set cht = ActiveSheet.ChartObjects(1).Chart
Set ax = cht.Axes(xlCategory)
ax.TickLabels.Font.Name = "Times"
End Sub