【问题标题】:Excel VBA: How can I select all of my Charts and change their sizes to a different, yet uniform size?Excel VBA:如何选择所有图表并将其大小更改为不同但统一的大小?
【发布时间】:2012-10-09 16:56:28
【问题描述】:

问题:我有一个包含大约 250 个图表的大文件,我一直在用如下代码格式化图表=

         With chrt
            .SetSourceData Source:=rChartData.Offset(0, 1).Resize(, 3)

            .SetElement msoElementChartTitleCenteredOverlay
            .ChartTitle.Caption = cl.Value

            .PlotArea.Height = .PlotArea.Height - .ChartTitle.Height
            .PlotArea.Top = .PlotArea.Top + .ChartTitle.Height

            .SeriesCollection(1).Name = "=""Measured"""
            .SeriesCollection(2).Name = "=""Modeled"""

            .SeriesCollection(1).MarkerStyle = -4142
            .SeriesCollection(2).MarkerStyle = -4142
            
            .Axes(xlCategory).MinimumScale = 14650
            .Axes(xlCategory).MaximumScale = 40000
            .Axes(xlCategory).MajorUnit = 1800
            .Axes(xlCategory).MinorUnitIsAuto = True

            .SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
                .Axes(xlCategory).AxisTitle.Text = "Stress Periods"
            .SetElement (msoElementPrimaryValueAxisTitleRotated)
                .Axes(xlValue, xlPrimary).AxisTitle.Text = "Cubic Feet/Sec"
       
       End With

然后它继续它的快乐循环以完成其他 249 个图表。但我也需要它们都大于 Excel 给我的默认大小。将我的图表扩展到更大尺寸(例如从 A 到 B)的正确代码术语是什么?

【问题讨论】:

  • 你可以试试 chrt.Parent.Width = SOMEVALUE 吗?

标签: excel vba charts formatting


【解决方案1】:

我找到了要添加到伞With语句的属性:

          .ChartArea.Width = [desired width, IN POINTS, of the object]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-10
    • 2016-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-30
    • 2019-01-21
    相关资源
    最近更新 更多