Change font of a hyperlink

Hello Everyone,

I insert a hyperlink in a Word file via Powershell. See code below:

$doc.Hyperlinks.Add($selection.Range,"$SiteUrl",'',"$SiteWeb","$SiteWeb")

But I have a little problem, the hyperlink takes a different font and size as the rest of the text that I insert the word file …
Do you know how I can do please?
Thank you !

Hi Florian, I’ve seen now two posts from you regarding manipulating word documents. I suggest you to look into these projects. They require however knowledge about programming, but with these projects you are able to manipulate docx contents in great depth.

https://github.com/OfficeDev/Open-XML-SDK
https://github.com/OfficeDev/Open-Xml-PowerTools

Hi Richard,

Thank you for the two links.

I’ll take a look, I have some experience in programming so it will have to go.

Nevertheless, this is the last point I have to finish my script. After that I will have certainnement need to work in it.

So if by chance someone knows the solution to change the font and size of a hyperlink in a word, let me know!

Florian

Solved !

$hlink = $doc.Hyperlinks.Add($selection.Range,"$SiteUrlB",'',"$SiteWebB","$SiteWebB")
    $hlink.Range.Font.Name = 'SFR Light'
    $hlink.Range.Font.Size = 10