PPT中对齐选定对象功能使用较为频繁,经常性对齐需要频繁点击图标,操作较为繁琐。
下述代码基本涵盖了PPT所有的原生对齐功能及置于顶层及底层的功能。
Tips:选定对象为单个时,使用下述功能会报错。
F1:: ;水平居中
ox := ComObjActive("PowerPoint.Application")
msoAlignMiddles :=4
msoFalse :=0
ox.ActiveWindow.Selection.ShapeRange.Align(msoAlignMiddles,msoFalse)
Return
F2:: ;垂直居中
ox := ComObjActive("PowerPoint.Application")
msoAlignCenters :=1
msoFalse :=0
ox.ActiveWindow.Selection.ShapeRange.Align(msoAlignCenters,msoFalse)
Return
F3:: ;顶端对齐
ox := ComObjActive("PowerPoint.Application")
msoAlignTops :=3
msoFalse :=0
ox.ActiveWindow.Selection.ShapeRange.Align(msoAlignTops,msoFalse)
Return
F4:: ;底端对齐
ox := ComObjActive("PowerPoint.Application")
msoAlignBottoms :=5
msoFalse :=0
ox.ActiveWindow.Selection.ShapeRange.Align(msoAlignBottoms,msoFalse)
Return
F5:: ;左对齐
ox := ComObjActive("PowerPoint.Application")
msoAlignLefts :=0
msoFalse :=0
ox.ActiveWindow.Selection.ShapeRange.Align(msoAlignLefts,msoFalse)
Return
F6:: ;右对齐
ox := ComObjActive("PowerPoint.Application")
msoAlignRights :=2
msoFalse :=0
ox.ActiveWindow.Selection.ShapeRange.Align(msoAlignRights,msoFalse)
Return
F7:: ;横向分布
ox := ComObjActive("PowerPoint.Application")
msoDistributeHorizontally :=0
msoFalse :=0
ox.ActiveWindow.Selection.ShapeRange.Distribute(msoDistributeHorizontally,msoFalse)
Return
F8:: ;纵向分布
ox := ComObjActive("PowerPoint.Application")
msoDistributeVertically :=1
msoFalse :=0
ox.ActiveWindow.Selection.ShapeRange.Distribute(msoDistributeVertically,msoFalse)
Return
F9:: ;置于顶层
ox := ComObjActive("PowerPoint.Application")
msoBringToFront :=0
ox.ActiveWindow.Selection.ShapeRange.Zorder(msoBringToFront)
Return
F10:: ;置于底层
ox := ComObjActive("PowerPoint.Application")
msoSendToBack :=1
ox.ActiveWindow.Selection.ShapeRange.Zorder(msoSendToBack)
Return