使用 Powershell 将幻灯片从一个 Powerpoint 演示文稿复制到另一个

Copying slides from one Powerpoint Presantation to another with Powershell

我想使用 Powershell 将幻灯片从一个 Powerpoint 演示文稿复制到另一个。 谁能帮帮我?

我的代码不起作用:

Add-type -AssemblyName office

$npath = “C:\p3.pptx"
$test = Test-Path $npath 
if($test = $true){Remove-Item $npath }

$ppo = New-Object -ComObject powerpoint.application 

$p1 = “C:\p1.pptx"
$p2 = “C:\p2.pptx"

$pp1 = $ppo.Presentations.open($p1)
$pp2 = $ppo.Presentations.open($p2)

$pp2.Slides.item(54).copy()
$pp1.Slides.item(54).paste()

#I have tried it too, but it doesn't work:
# $cs = $pp2.Slides.item(54)
# $pp1.Slides.item(54).copy($cs)

$pp1.Saveas($npath)
$pp1.Close()
$pp2.Close()

$ppo.quit()
$ppo = $null

尝试使用此方法:

$pp2.Slides.InsertFromFile($p1,54,54,54)

语法: FileName:=“C:\p1.pptx”, Index:=54 (在新ppt中), SlideStart:=54, SlideEnd:=54

无需复制粘贴。