答案1
下面是我维护的 PowerPoint FAQ 网站上的一个页面的代码示例:
在 PPT 2013 及更高版本中使用参考线 http://www.pptfaq.com/FAQ01214-Working-with-Guides-in-PPT-2013-and-later.htm
如果您不习惯使用 VBA,该页面底部有一个简单教程的链接。
这样您就可以在任意位置添加水平/垂直参考线:
Sub AddGuides()
Dim HGuides As String
Dim VGuides As String
Dim x As Long
Dim aGuideArray() As String
' Edit these to indicate where you'd like to put guides:
' Values are in points, 72 points to the inch
' Separate each value from the next with a pipe | character
' Horizontal guide positions:
HGuides = "72|144|256.5"
' Vertical guide positions:
VGuides = "10|20|30|40|50|60|70|80|90|100"
With ActivePresentation
' nb ppHorizonatalGuide = 1; ppVerticalGuide = 2
' nb to add guides to master rather than slides,
' use .SlideMaster.Guides.Add below
' in place of .Guides.Add
' First add the horizontal guides
aGuideArray = Split(HGuides, "|")
For x = LBound(aGuideArray) To UBound(aGuideArray)
.Guides.Add ppHorizontalGuide, CSng(aGuideArray(x))
Next
' and now the vertical guides
aGuideArray = Split(VGuides, "|")
For x = LBound(aGuideArray) To UBound(aGuideArray)
.Guides.Add ppVerticalGuide, CSng(aGuideArray(x))
Next
End With
End Sub