1
我想将Powerpoint Presantation中的幻灯片复制到另一个PowerShell中。 任何人都可以帮助我吗?使用Powershell将幻灯片从一个Powerpoint Presantation复制到另一个
这里是我的代码无法正常工作:
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.Item(x).Delete() –
它工作正常! 非常感谢! –
欢迎您。你能接受作为答案! –