简体   繁体   English

如何在 PowerPoint VBA 中使用每张新幻灯片增加形状微调的大小?

[英]How to increase the size of a shape nudge with each new slide in PowerPoint VBA?

This code creates a string of 10 slides, in which each next slide's 2 shapes (number 1 and number 3) are nudged a bit in relation to similar shapes in the previous slide, while one shape (number 2) remains in the same position throughout.此代码创建一串 10 张幻灯片,其中每张下一张幻灯片的 2 个形状(编号 1 和编号 3)相对于上一张幻灯片中的相似形状略微微移,而一个形状(编号 2)始终保持在相同位置.

Each nudge is equal to 2 points (pixels?), but I wonder how could I modify this code so that each nudge would be greater than the previous one by one point.每个微调等于 2 点(像素?),但我想知道如何修改此代码,使每个微调都比前一个一个点大。 For example, the nudge for creating slide 2 would be 2 points, but the nudge for slide 3 will be 3 points, etc.例如,创建幻灯片 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

Just replace:只需更换:

oShape.Left = oShape.Left + 2

...with: ...与:

oShape.Left = oShape.Left + slideNumber

(although you might want to use slideNumber * 10 to make it noticeable). (尽管您可能希望使用 slideNumber * 10 使其引人注目)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM