vba - 将幻灯片从模板 PPT 复制/粘贴到打开的 PPT 中的当前位置
问题描述
我正在尝试组合一个宏,以便在运行它时将幻灯片从模板演示文稿复制/粘贴到活动演示文稿中的当前幻灯片之后。我已经完成了 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
推荐阅读
- excel - 选择 TCD 中的项目
- jupyter - 如何在 TAILS OS 上使用 Jupyter notebook
- angular - app-sidebar-nav 的 navItems 未更新
- json - 如何将json api中的数据发布到flutter列表中
- angular - 得到这是空的
- node.js - nodeJS从文件中插入数据
- ios - NSUrlDomainError 代码 -1002 “不支持的 URL”
- javascript - 将数组从 Django 视图传递到 HTML/JS
- swift - 在 Swift 中返回 nil 的字典值
- sql-server - 目标主体名称不正确。无法生成 SSPI 上下文。在.Net MVC 中