首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将幻灯片从模板PPT复制/粘贴到打开PPT中的当前位置

将幻灯片从模板PPT复制/粘贴到打开PPT中的当前位置
EN

Stack Overflow用户
提问于 2020-12-02 02:01:16
回答 1查看 141关注 0票数 1

我试图将宏放在一起,以便在运行它时,它会将幻灯片从模板演示文稿复制/粘贴到当前幻灯片之后的活动演示文稿中。我有90%的路在那里,但似乎不知道如何使粘贴部分发挥所需的作用。我所能找到的就是如何将它粘贴到指定的位置(例如幻灯片4)或演示文稿的末尾。

这是我到目前为止提到的MS资源:https://learn.microsoft.com/en-us/office/vba/api/powerpoint.slides.paste

这是我的代码的当前版本:

代码语言:javascript
复制
  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

谢谢你的帮忙!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-04 10:15:59

以下是解决办法,终于能够找到答案:

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65101179

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档