Microsoft Office Tutorials and References
In Depth Information
Freezing the text size of chart elements
Axis Type
How to Reference It
Primary Category (X) Axis
Axes(xlCategory, xlPrimary)
Primary Value (Y)( Axis
Axes(xlValue, xlPrimary)
Secondary Category (X) Axis
Axes(xlCategory, xlSecondary)
Secondary Value (Y) Axis
Axes(xlValue, xlSecondary)
Series Axis
Keep in mind that the properties for an Axis object vary, depending on the type.
For example, a category axis does not have the properties used in the preceding
macro — unless its specified as a time-scale category axis. To make a category axis
a time-scale axis, use a statement like this:
ActiveChart.Axes(xlCategory).CategoryType = xlTimeScale
Other CategoryType settings are xlCategoryScale and xlAutomatic . These
correspond to the options available in the Axes tab of the Chart Options dialog box.
Freezing the text size of chart elements
You’ve probably noticed that the chart elements that display text are set to “auto
scale” by default. When you change the size of the chart, the text size adjusts
accordingly. In some cases, this is a good thing. But sometimes this automatic
behavior can be very annoying and force you to do unnecessary editing after
resizing a chart.
To turn off auto font scaling for all chart elements manually, access the Font tab
of the Format Chart Area dialog box and remove the checkmark from the Auto
Scale check box. However, doing this has an undesirable side effect: All text
elements in the chart will have the same font formatting as the chart area!
Oddly, if you use VBA to set the AutoScaleFont property of the ChartArea
object to False, this undesirable side effect does not occur. All the chart elements
that contain text will also have their AutoScaleFont property set to False, but their
current font settings will not change.
The FreezeTextSize macro that follows takes advantage of this quirk. It sets
the AutoScaleFont property of the ChartArea object to False, and essentially
freezes the font size of all chart elements that contain text.
Search JabSto ::

Custom Search