Change font of a hyperlink

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of Florian Schinas Florian Schinas 7 months, 3 weeks ago.

  • Author
    Posts
  • #37721
    Profile photo of Florian Schinas
    Florian Schinas
    Participant

    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 !

  • #37739
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

    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

  • #37740
    Profile photo of Florian Schinas
    Florian Schinas
    Participant

    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

  • #38050
    Profile photo of Florian Schinas
    Florian Schinas
    Participant

    Solved !

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

You must be logged in to reply to this topic.