Skip to content

Commit

Permalink
Show example for #1
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzemyslawKlys committed Apr 21, 2022
1 parent af0e9a1 commit dd30d63
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Examples/ExampleWord08-Hyperlinks.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This is just a show what can be quickly done using .NET before I get to do it's PowerShell version

Clear-Host
Import-Module .\PSWriteOffice.psd1 -Force

$Document = New-OfficeWord -FilePath $PSScriptRoot\Documents\BasicDocumentWithHyperlinks.docx
$Document.BuiltinDocumentProperties.Title = "This is title"
$Document.BuiltinDocumentProperties.Subject = "This is subject aka subtitle"

$null = $Document.AddHyperLink("Google", [uri] "https://www.google.com")

$Null = $Document.AddHyperLink("Evotec", [uri] "https://evotec.xyz", $true, "Tooltip for hyperlink", $false)


$Document.HyperLinks.Count

foreach ($HyperLink in $Document.HyperLinks) {
if ($HyperLink.IsEmail) {
Write-Host -Object "Email: $($HyperLink.EmailAddress)"
} elseif ($HyperLink.IsHttp) {
Write-Host -Object "URL: $($HyperLink.Uri)"
} else {
Write-Host -Object "Text: $($HyperLink.Text)"
}
# display properties of hyerlink
$HyperLink | Format-Table

}

Save-OfficeWord -Document $Document -Show

0 comments on commit dd30d63

Please sign in to comment.