如何使用PowerPoint VBA中的每个新幻灯片增加形状轻推?

时间:2009-11-11 18:51:43

标签: powerpoint powerpoint-vba

此代码创建一个包含10个幻灯片的字符串,其中每个下一个幻灯片的2个形状(数字1和数字3)相对于上一张幻灯片中的相似形状略微轻微一点,而一个形状(数字2)保留在同样的位置。

每个微调等于2个点(像素?),但是我想知道如何修改这个代码,以便每个微调都比前一个微调大一点。例如,创建幻灯片2的轻推将是2分,但幻灯片3的轻推将是3分等。

Sub MovingFlanks()
    Dim oPresentation As Presentation
    Set oPresentation = ActivePresentation
    Dim oSlide As Slide 
    Dim oSlides As SlideRange
    Dim oShape As Shape
    Dim slideNumber As Integer
    For slideNumber = 1 To 10
        Set oSlide = oPresentation.Slides(oPresentation.Slides.Count)
        oSlide.Copy
        Set oNewSlides = oPresentation.Slides.Paste()
        Set oSlide = oNewSlides(1)
        Set oShape = oSlide.Shapes(1)   
        For Each shapeNum In Array(1, 3)
            Set oShape = oSlide.Shapes(shapeNum)
            oShape.Left = oShape.Left + 2 
        Next shapeNum
    Next slideNumber
End Sub

1 个答案:

答案 0 :(得分:3)

只需替换:

oShape.Left = oShape.Left + 2

...与:

oShape.Left = oShape.Left + slideNumber

(尽管您可能希望使用slideNumber * 10使其显而易见)。