PowerPoint 宏 - 粘贴幻灯片并保留源格式

PowerPoint Macro - Paste Slides and Keep Source Formatting

我有一组核心幻灯片,我将其插入保存在桌面上的所有演示文稿中。我写了一个宏来复制这些幻灯片并将它们粘贴到当前打开的演示文稿中,但我丢失了源格式。我读了一些其他做类似事情的帖子,但我似乎无法让 ExecuteMso 命令工作:

Sub insertSlides()
    
    Dim objPresentation As Presentation
    Dim currPresentation As Presentation
    Set currPresentation = Application.ActivePresentation
    
    Set objPresentation = Presentations.Open("C:\Users\Me\Desktop\coreSlides.pptx", , False)
    objPresentation.Slides.Item(1).Copy
    currPresentation.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")
    objPresentation.Close
    
 End Sub

另外,您能否使用此命令始终在第 2 张幻灯片之后粘贴一张幻灯片?

我在您的代码中添加了一行,对我来说效果很好,并在保持原始格式的情况下粘贴了幻灯片。 currPresentation.Windows.Item(1).Activate

但是幻灯片的大小没有保存,如果需要的话可以根据原演示文稿中的大小明确设置。

Sub insertSlides()
    
    Dim objPresentation As Presentation
    Dim currPresentation As Presentation
    Set currPresentation = Application.ActivePresentation
    
    Set objPresentation = Presentations.Open("F:.pptx", , False)
    objPresentation.Slides.Item(1).Copy
    currPresentation.Windows.Item(1).Activate ' NEW LINE !
    currPresentation.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")
    objPresentation.Close
    
 End Sub