Copy/pasting从模板PPT滑动到打开PPT中的当前位置
Copy/pasting slide from template PPT to current location in open PPT
我正在尝试组合一个宏,这样当我 运行 它时,它 copy/pastes 从模板演示文稿到当前幻灯片 之后的幻灯片 在活动演示文稿中。我已经完成了 90%,但似乎无法弄清楚如何使粘贴部分发挥所需的作用。我只能找到如何将其粘贴到指定位置(例如幻灯片 4)或演示文稿末尾。
这是我到目前为止提到的 MS 资源:https://docs.microsoft.com/en-us/office/vba/api/powerpoint.slides.paste
这是我的代码的当前版本:
Sub PastefromTemplate()
Dim tgt, i%
'open the target presentation
'use path with the file if it is in a different location
Set objPresentation = Presentations.Open("source path")
'copy slide 1 from source presentation
'change the item number in order to target a different slide
objPresentation.Slides.Item(1).Copy
'paste the slide in target, currently set to slide 3
tgt = Array(3)
Presentations.Item(1).Slides.Paste tgt i
objPresentation.Close
End Sub
感谢您的帮助!
这里是解决方案,终于弄明白了:
Sub Slide9()
Dim src As Presentation
Dim trg As Slide
Dim shp As Shape
Dim target As Presentation
'Copies slide (change # in Item(#)) from the source presentation
Set objPresentation = Presentations.Open("source file path")
objPresentation.Slides.Item(9).Copy
'Closes the source presentation
objPresentation.Close
'Go back to active presentation and paste, then go to pasted slide
With ActiveWindow.View
.Paste
.GotoSlide (ActiveWindow.View.Slide.SlideIndex)
End With
End Sub
我正在尝试组合一个宏,这样当我 运行 它时,它 copy/pastes 从模板演示文稿到当前幻灯片 之后的幻灯片 在活动演示文稿中。我已经完成了 90%,但似乎无法弄清楚如何使粘贴部分发挥所需的作用。我只能找到如何将其粘贴到指定位置(例如幻灯片 4)或演示文稿末尾。
这是我到目前为止提到的 MS 资源:https://docs.microsoft.com/en-us/office/vba/api/powerpoint.slides.paste
这是我的代码的当前版本:
Sub PastefromTemplate()
Dim tgt, i%
'open the target presentation
'use path with the file if it is in a different location
Set objPresentation = Presentations.Open("source path")
'copy slide 1 from source presentation
'change the item number in order to target a different slide
objPresentation.Slides.Item(1).Copy
'paste the slide in target, currently set to slide 3
tgt = Array(3)
Presentations.Item(1).Slides.Paste tgt i
objPresentation.Close
End Sub
感谢您的帮助!
这里是解决方案,终于弄明白了:
Sub Slide9()
Dim src As Presentation
Dim trg As Slide
Dim shp As Shape
Dim target As Presentation
'Copies slide (change # in Item(#)) from the source presentation
Set objPresentation = Presentations.Open("source file path")
objPresentation.Slides.Item(9).Copy
'Closes the source presentation
objPresentation.Close
'Go back to active presentation and paste, then go to pasted slide
With ActiveWindow.View
.Paste
.GotoSlide (ActiveWindow.View.Slide.SlideIndex)
End With
End Sub