Author Posts

April 14, 2016 at 1:14 am

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 !

April 14, 2016 at 3:41 am

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

April 14, 2016 at 3:44 am

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

April 20, 2016 at 5:37 am

Solved !

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