首先,我是VBA的新手。
我想将一张形状从一张幻灯片移动到下一张幻灯片。我想为演示文稿的每张幻灯片做这件事。 (在编辑模式下)
Dim Sld As Slide
Dim Shp As Shape
For Each Sld In ActivePresentation.Slides
For Each Shp In Sld.Shapes
With Shp
If .Type = msoAutoShape _
And .Left = 715 _
And .Top = 366 _
Then
/!\ In the next slide /!\
.Left = 50 'change the number for desired x position
.Top = 50 'change the number for desired y position
End If
End With
Next 'Shape
Next Sld ' Slide
这是我到目前为止的代码。它正在努力在同一张幻灯片中移动形状,但我真的不知道要添加什么在下一张幻灯片中移动形状。
提前感谢您的帮助。
答案 0 :(得分:0)
这里有一个应该有用的小片段:
' Copy the shape to the clipboard:
Shp.Copy
' Paste the shape to the next slide
' Shp.Parent gives you a reference to the slide the shape is on
' Shp.Parent.SlideIndex + 1 gives you a reference to the NEXT slide
ActivePresentation.Slides(Shp.Parent.SlideIndex + 1).Shapes.Paste
' And delete the original shape
Shp.Delete
当然,您需要确保确实存在下一张幻灯片。 ActivePresentation.Slides.Count会告诉你有多少张幻灯片。