如何使用 Powershell 将文本插入现有的 Powerpoint 幻灯片

How to insert text to an existing Powerpoint Slide using Powershell

我尝试了三种不同的方法,但都无济于事。

首先是:

$s = $presentation.Slides[$targetslide]


$tb = $s.Shapes.AddTextbox($horiz,$left,$top,$width,$height) 
$tb.TextFrame.TextRange.Text = $fla

第二个是:

$f0a = ''
#$f1a is text to insert 
$presentation.Slides[$targetslide].Shapes[1].TextFrame.TextRange.Replace($f0a, $f1a)

第三个是:

$s = $presentation.Slides[$targetslide]



$s.Shape[1].TextFrame.TextRange.Text = $fla

似乎都不起作用。你对我应该尝试什么有什么建议吗?

显然,

$f0a=$s.Shapes[5].TextFrame.TextRange.Text

$test = $s.Shapes[5].TextFrame.TextRange.Replace($f0a, $f1a)

完美运行。