如何使用Powershell在PowerPoint中创建超链接

我是powershell的新生。我正在为新的PowerPoint文件编写一些代码,并向本地文件插入一些超链接。但是找不到示例代码。

zzcool0102 回答:如何使用Powershell在PowerPoint中创建超链接

If (test-path HKLM:SOFTWARE\Classes\PowerPoint.Application) {
$powerPointFileName = "TestPowerPoint"
Write-Output "Microsoft PowerPoint installed. Start to create PowerPoint file:$powerPointFileName"
$PPT = New-Object -ComObject PowerPoint.Application
$PPT.Visible = [Microsoft.Office.Core.MsoTriState]::msoTrue
$slideType = "microsoft.office.interop.powerpoint.ppSlideLayout" -as [type]
$presentation = $PPT.Presentations.Add()
$newSlide = $presentation.Slides.add($presentation.Slides.Count + 1,3)
$newSlide.Shapes.title.TextFrame.TextRange.Text ="Test Update Hyperlinks"
$newSlide.shapes.item(2).TextFrame.TextRange.Text = "Test Link 1"
$newSlide.shapes.item(2).TextFrame.TextRange.ActionSettings(1).Hyperlink.Address = "C:\readme.doc"
$newSlide.shapes.item(3).TextFrame.TextRange.Text = "Test Link 2"
$newSlide.shapes.item(3).TextFrame.TextRange.ActionSettings(1).Hyperlink.Address = "C:\test\readme.doc"

$presentation.SaveAs("C:\$powerPointFileName")
$presentation.Close()
$PPT.Quit()
$PPT = $null
Get-Process "PowerPNT" | Stop-Process -Force
[gc]::collect()
[gc]::WaitForPendingFinalizers()
} else {
Write-Output "No PowerPoint is installed. Cancel to create PowerPoint file."
}
本文链接:https://www.f2er.com/3146240.html

大家都在问