vba - Powerpoint VBA - 调整图表和轴标题的位置
问题描述
我有以下代码:
Sub StandardiseChart(ByVal control As IRibbonControl)
Dim activeShape As Shape
'Determine Which Shape is Active
If ActiveWindow.Selection.Type = ppSelectionShapes Then
'Loop in case multiples shapes selected
Dim shp As Shape
For Each shp In ActiveWindow.Selection.ShapeRange
Set activeShape = shp ' First shape selected
Exit For
Next
'Now, reformat the selected shape if it is a chart
With activeShape
If .HasChart Then
' Chart title
.Chart.HasTitle = True
With .Chart.ChartTitle
.Left = 0
.Top = 0
End With
' Y axis
With .Chart.Axes(xlValue, xlPrimary)
.HasTitle = True
.AxisTitle.Text = "Placeholder"
.AxisTitle.Left = 0
.AxisTitle.Top = 20
.AxisTitle.Orientation = 0
End With
' Plot Area
With .Chart.PlotArea
.Left = 10
.Top = 50
End With
End If
End With ' activeShape
End If
End Sub
我想做的是三件事:
- 将图表标题固定到整个对象的左上角(这看起来不错)
- 设置 y 轴标题,使其与图表标题之间有 20pt 的空间(看起来也不错)
- 在绘图区域和 y 轴标题之间再创建 50pt 的空间(不好)。
无论我做什么(我尝试将数字调整为 70 而不是 50,甚至更大),我似乎都无法调整空间来实现(3)。具体来说,无论我做什么,情节区域都不会移动。
我究竟做错了什么?
解决方案
如果在 Chart.Plotarea 的末尾添加一个点,则可以看到方法列表。在您的情况下,您正在寻找.InsideLeft和.InsideTop,因为您想调整与图表区域的内部距离:
With .Chart.PlotArea
.InsideLeft = 70
.InsideTop = 70
End With
推荐阅读
- javascript - Javascript多态性:如何在(“抽象”)基类的静态方法中访问继承类的静态属性?
- android - BottomAppBar 中未显示菜单项文本
- elixir - Elixir Ecto,无法将类型更改为 jsonb
- emacs - Emacs 启动 Repl 时出错
- tomcat - 如何更改 Grails 2 的 Tomcat 7 插件源
- python - 有没有办法从python中的数组中删除相似的(数字)元素
- webpack - Webpack watch 和 Font Awesome:缺少 webfont 文件
- ruby-on-rails - Heroku/Rails 上的 Chromedriver:无法加载应用程序:Selenium::WebDriver::Error::WebDriverError:不是文件:“/usr/local/bin/chromedriver”
- django - 在用户需要时调用 django 查询集
- android - Bitmap.createBitmap 将所有像素设置为 0