如何使用Powershell在PowerPoint中创建超链接
我是powershell的新生。我正在为新的PowerPoint文件编写一些代码,并插入一些指向本地文件的超链接。但是没有可找到的示例代码。查找一个好的MS Office库,获取一些.NET代码示例并将它们重写为PuthScript脚本。@ MassZe您会考虑添加一些参考链接到您认为是好的MS Office Label.NET代码吗?如何使用Powershell在PowerPoint中创建超链接,powershell,hyperlink,powerpoint,Powershell,Hyperlink,Powerpoint,我是powershell的新生。我正在为新的PowerPoint文件编写一些代码,并插入一些指向本地文件的超链接。但是没有可找到的示例代码。查找一个好的MS Office库,获取一些.NET代码示例并将它们重写为PuthScript脚本。@ MassZe您会考虑添加一些参考链接到您认为是好的MS Office Label.NET代码吗? If (test-path HKLM:SOFTWARE\Classes\PowerPoint.Application) { $powerPointFileNam
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."
}