{"id":17961,"date":"2010-06-24T00:01:00","date_gmt":"2010-06-24T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/06\/24\/hey-scripting-guy-how-can-i-use-windows-powershell-to-add-hyperlinks-to-a-word-document\/"},"modified":"2010-06-24T00:01:00","modified_gmt":"2010-06-24T00:01:00","slug":"hey-scripting-guy-how-can-i-use-windows-powershell-to-add-hyperlinks-to-a-word-document","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-how-can-i-use-windows-powershell-to-add-hyperlinks-to-a-word-document\/","title":{"rendered":"Hey, Scripting Guy! How Can I Use Windows PowerShell to Add Hyperlinks to a Word Document?"},"content":{"rendered":"<p><a href=\"http:\/\/www.addthis.com\/bookmark.php?v=250&amp;pub=scriptingguys\"><\/p>\n<p><img decoding=\"async\" height=\"16\" width=\"125\" src=\"http:\/\/s7.addthis.com\/static\/btn\/v2\/lg-share-en.gif\" alt=\"Bookmark and Share\" border=\"0\" \/><\/p>\n<p><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Question\" border=\"0\" title=\"Hey, Scripting Guy! Question\" \/><\/p>\n<p>Hey, Scripting Guy! I need to add hyperlinks to a document by using <a href=\"http:\/\/technet.microsoft.com\/en-us\/scriptcenter\/powershell.aspx\">Windows PowerShell<\/a>. But I do not want to add hyperlinks to objects that are set in a code style or a heading style. I only want to add the hyperlink to the word if it is in a normal <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb244515(v=office.12).aspx\">Microsoft Word<\/a> style. In addition, I only want to add the link one time per document. Can this be done, and if so how tough would it be to create such a script? I would be forever grateful because the script would save me an awful lot of time every week. <\/p>\n<p>&#8212; EW<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" height=\"34\" width=\"34\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" align=\"left\" alt=\"Hey, Scripting Guy! Answer\" border=\"0\" title=\"Hey, Scripting Guy! Answer\" \/><\/p>\n<p>Hello EW, <\/p>\n<p>Microsoft Scripting Guy Ed Wilson here. It is another hot humid day in <a href=\"http:\/\/en.wikipedia.org\/wiki\/Charlotte,_North_Carolina\">Charlotte<\/a>, <a href=\"http:\/\/en.wikipedia.org\/wiki\/North_Carolina\">North Carolina<\/a>, in the United States. Today is a pretty cool day, however, because I have a couple of meetings that are always the highlight of my week. The first meeting is my weekly meeting with my alter ego, Craig; I always come away from those meetings inspired with great ideas, projects, and cool things we can do to better interact with the community. In addition, Craig always has cool ideas about things we can do around the <a href=\"http:\/\/technet.microsoft.com\/en-us\/scriptcenter\/default.aspx\">Script Center<\/a> to make things easier to find. The second meeting is with our site manager, Ian. Ian is new to our team but he is quickly becoming the go-to person for helping to get our Script Center spruced up. The other meeting that I always enjoy is the Knowledge Engineers meeting. Knowledge Engineers are a group of people who are exploring various ways to interact with the community. <\/p>\n<p>Well, I digress. I decided I needed my large teapot today because I will be on <a href=\"http:\/\/office.microsoft.com\/en-us\/help\/microsoft-office-live-meeting-resource-center-HA010238900.aspx?CTT=1\">Live Meeting<\/a> for a total of four and a half hours today. <a href=\"http:\/\/en.wikipedia.org\/wiki\/Earl_Grey_tea\">Earl Grey tea<\/a> is my favorite for afternoon meetings, especially when accompanied by a small plate stacked with <a href=\"http:\/\/en.wikipedia.org\/wiki\/Anzac_biscuit\">ANZAC biscuits<\/a>. <\/p>\n<p>EW, because I like to pay attention when I am in meetings, I want to go ahead and get your Windows PowerShell script written before my first meeting. The complete ReadTextFileAddHyperLinksToDocument.ps1 script is shown here. <\/p>\n<p><strong>ReadTextFileAddHyperLinksToDocument.ps1<\/strong><\/p>\n<p><span style=\"background-color: #e6e6e6\">[cmdletBinding()]   <br \/>Param(    <br \/>$wordFile = &#8220;C:\\fso1\\words.CSV&#8221;,    <br \/>$docPath = &#8220;C:\\fso1\\TestHSG.Doc&#8221;    <br \/>) #end param    <br \/>add-type -AssemblyName &#8220;Microsoft.Office.Interop.Word&#8221;     <br \/>$wdunits = &#8220;Microsoft.Office.Interop.Word.wdunits&#8221; -as [type]    <br \/>$application = New-Object -comobject word.application    <br \/>$application.visible = $False    <br \/>$words = Import-Csv $wordFile    <br \/>$docs = Get-childitem -Path $docPath -Include *.doc,*.docx -Recurse    <br \/>Foreach ($doc in $docs)    <br \/>{    <br \/>Write-Verbose -Message &#8220;Processing $($doc.fullname)&#8221;    <br \/>$document = $application.documents.open($doc.FullName)    <br \/>$range = $document.content    <br \/>$null = $range.movestart($wdunits::wdword,$range.start)    <br \/>$matchCase = $false    <br \/>$matchWholeWord = $true    <br \/>$matchWildCards = $false    <br \/>$matchSoundsLike = $false    <br \/>$matchAllWordForms = $false    <br \/>$forward = $true    <br \/>$wrap = 1    <br \/>Foreach ($word in $words)    <br \/>{    <br \/>$findText = $word.Word    <br \/>write-verbose -Message &#8220;looking for $($findText)&#8221;    <br \/>$wordFound = $range.find.execute($findText,$matchCase,    <br \/>$matchWholeWord,$matchWildCards,$matchSoundsLike,    <br \/>$matchAllWordForms,$forward,$wrap)    <br \/>Write-Verbose -Message &#8220;$($findText) returned $wordFound&#8221;    <br \/>if($wordFound)     <br \/>{    <br \/>if($Range.style.namelocal -eq &#8220;normal&#8221;)    <br \/>{$null = $document.HyperLinks.Add($Range, $word.URL,$null,$null,$FindText)}    <br \/>ELSE    <br \/>{    <br \/>Write-Verbose -Message `    <br \/>&#8220;$($findText) not modified because it is $($Range.style.namelocal)&#8221;    <br \/>}    <br \/>} #end if $wordFound    <br \/>$range = $document.content    <br \/>$null = $range.movestart($wdunits::wdword,$range.start)    <br \/>$wordFound = $false    <br \/>} #end foreach $word    <br \/>$document.save()    <br \/>$document.close()    <br \/>} #end foreach $doc    <br \/>$application.quit()    <br \/>Remove-Variable -Name application    <br \/>[gc]::collect()    <br \/>[gc]::WaitForPendingFinalizers()<\/span><\/p>\n<p>Suppose you have a Microsoft Word document such as the one seen in the following image, and you want to add a large number of hyperlinks to it. Rather than opening it up and doing everything manually, using a script makes more sense. <\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4380.hsg062410012_4AA754E8.jpg\"><img decoding=\"async\" height=\"434\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8510.hsg062410012_thumb_61862664.jpg\" alt=\"Image of a Office Word document\" border=\"0\" title=\"Image of a Office Word document\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" \/><\/a> <\/p>\n<p>The first thing that needs to be done is to create the command-line parameters. In addition, you will want to specify <strong>cmdletBinding<\/strong> to allow the script to take advantage of <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dd315352.aspx\">common parameters<\/a>. By taking advantage of common parameters, you do not need to add additional code to your script to permit it to properly support parameters such as verbose. The <strong>param<\/strong> statement is used to create two command-line parameters: the first is the path to the word file and the second is the path to the document to be processed. The value of <strong>&ndash;wordfile<\/strong> is a CSV file that consists of two values: word and URL. An example of such a CSV file is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8883.hsg062410021_0F074628.jpg\"><img decoding=\"async\" height=\"319\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7433.hsg062410021_thumb_60ADC07A.jpg\" alt=\"Image of example CSV file\" border=\"0\" title=\"Image of example CSV file\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" \/><\/a> <\/p>\n<p>The <strong>&ndash;docpath<\/strong> parameter can point to a single Microsoft Word document or a folder that contains Microsoft Word documents. If you supply a folder, you only need to supply the folder path. The first few times you run the script, you will probably wish to run it with the <strong>&ndash;verbose<\/strong> common parameter. This is shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">PS C:\\&gt; C:\\SG\\ReadTextFileAddHyperLinksToDocument.ps1 -docPath c:\\fso &ndash;Verbose<\/span><\/p>\n<p>When the script is run with the <strong>&ndash;verbose<\/strong> parameter, the output appears that is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6431.hsg062410031_4745BD40.jpg\"><img decoding=\"async\" height=\"424\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5861.hsg062410031_thumb_2DDDBA06.jpg\" alt=\"Image of script output from running script with -verbose parameter\" border=\"0\" title=\"Image of script output from running script with -verbose parameter\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" \/><\/a> <\/p>\n<p>This section of the script is shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">[cmdletBinding()]   <br \/>Param(    <br \/>$wordFile = &#8220;C:\\fso1\\words.CSV&#8221;,    <br \/>$docPath = &#8220;C:\\fso1\\TestHSG.Doc&#8221;    <br \/>) #end param<\/span><\/p>\n<p>Next, the <strong>Add-Type<\/strong> cmdlet is used to ensure the Microsoft Word interop assembly is loaded. Then, the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb214015(v=office.12).aspx\">WdUnits enumeration<\/a> is created. The <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb244569(v=office.12).aspx\">Microsoft Word Application Object<\/a> is created, and the <strong>visible<\/strong> property of the <strong>application<\/strong> object is set to <strong>False<\/strong>. This is shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">add-type -AssemblyName &#8220;Microsoft.Office.Interop.Word&#8221;    <br \/>$wdunits = &#8220;Microsoft.Office.Interop.Word.wdunits&#8221; -as [type]    <br \/>$application = New-Object -comobject word.application    <br \/>$application.visible = $False<\/span><\/p>\n<p>Because the Word file is stored as a comma-separated value (CSV) file, the <strong>Import-CSV<\/strong> cmdlet is used to import the contents into the <strong>$words<\/strong> variable. The <a href=\"http:\/\/www.bing.com\/visualsearch?g=powershell_cmdlets&amp;FORM=Z9GE22#toc=0&amp;s=2&amp;r=2\">Get-ChildItem cmdlet<\/a> is used to retrieve an array of <strong>fileinfo<\/strong> objects and store the results in the <strong>$docs<\/strong> variable. This cmdlet will work even if a specific file is added to the <strong>&ndash;docpath<\/strong> parameter. This section of the script is shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">$words = Import-Csv $wordFile   <br \/>$docs = Get-ChildItem Path $docPath -Include *.doc,*.docx -Recurse<\/span><\/p>\n<p>When the script is run with the <strong>&ndash;verbose<\/strong> parameter, a status message is displayed that states the name of the document currently being processed. In addition, a message about an interop assembly is displayed. It says, &ldquo;The object is being written to the pipeline&hellip;&rdquo; even if the object is not piped. In addition, it states that the interop assembly should be installed; however, the interop assembly is loaded. Keep in mind this message is verbose, not a warning or an error. A Microsoft Word <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb211897(v=office.12).aspx\">Document object<\/a> is created when the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb216319(v=office.12).aspx\">Document object&rsquo;s Open method<\/a> is called. The <strong>document<\/strong> object&rsquo;s <strong>open<\/strong> method has a number of optional parameters, including the ability to supply a password. The document object is stored in the <strong>$document<\/strong> variable. The output is shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">VERBOSE: The object written to the pipeline is an instance of the type   <br \/>&#8220;Microsoft.Office.Interop.Word.ApplicationClass&#8221; from the component&#8217;s primary    <br \/>interop assembly. If this type exposes different members than the IDispatch members,    <br \/>scripts written to work with this object might not work if the primary interop    <br \/>assembly is not installed.    <br \/>VERBOSE: Processing C:\\fso\\HSG-6-1-10.Doc<\/span><\/p>\n<p>This section of the script is shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">Foreach ($doc in $docs)   <br \/>{    <br \/>Write-Verbose -Message &#8220;Processing $($doc.fullname)&#8221;     <br \/>$document = $application.documents.open($doc.FullName)<\/span><\/p>\n<p>The <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb223687(v=office.12).aspx\">Document object&rsquo;s Content property<\/a> returns a <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb257694(v=office.12).aspx\">Range object<\/a> that represents the main document story. This Range object will be used to work with the text in the document. The <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb217039(v=office.12).aspx\">Range object&rsquo;s MoveStart method<\/a> moves the start position of the <strong>Range<\/strong> object to the beginning of the range. To do this, it is necessary to specify which units to use; in this example, words are used as the unit of measure. Next, the position itself is specified. The position used here is the <strong>Range<\/strong> object&rsquo;s <strong>Start<\/strong> property. The units are an instance of a <strong>WdUnit<\/strong> enumeration value. This section of the script is seen here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">$range = $document.content   <br \/>$null = $range.movestart($wdunits::wdword,$range.start)<\/span><\/p>\n<p>Now a number of variables used for the parameters for the <strong>Execute<\/strong> method of the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb258967(v=office.12).aspx\">Find object<\/a> are initialized. These are shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">$matchCase = $false   <br \/>$matchWholeWord = $true    <br \/>$matchWildCards = $false    <br \/>$matchSoundsLike = $false    <br \/>$matchAllWordForms = $false    <br \/>$forward = $true    <br \/>$wrap = 1<\/span><\/p>\n<p>Then each word in the array of words from the wordlist.csv file is processed. The value of the <strong>word<\/strong> property is assigned to the <strong>$findText<\/strong> variable. A verbose status message is displayed on the Windows PowerShell console when the script is run with the <strong>&ndash;verbose<\/strong> parameter. The <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb179352(v=office.12).aspx\">Find object&rsquo;s Execute method<\/a> is used to locate the first occurrence of the word. The <strong>Execute<\/strong> method returns a Boolean value. <\/p>\n<p>When the <strong>Find<\/strong> object is used from a <strong>Range<\/strong> object (as is the case here), the <strong>Range<\/strong> object is redefined to match the result of the <strong>Find<\/strong> operation. This is the reason for redefining the range later on in the script. If the <strong>Find<\/strong> object is created from a <strong>Selection<\/strong> object, the selection is changed when the text that matches the find criteria is found. If the Microsoft Word document is visible when using find from a <strong>Selection<\/strong> object, the matching text will change colors. The active selection could then be used to obtain a <strong>Range<\/strong> object to use when adding a hyperlink. By using a <strong>Range<\/strong> object to launch find, I remove one step in the process. <\/p>\n<p>This section of the script is shown here. <\/p>\n<p><span style=\"background-color: #e6e6e6\">Foreach ($word in $words)   <br \/>{    <br \/>$findText = $word.Word    <br \/>write-verbose -Message &#8220;looking for $($findText)&#8221;    <br \/>$wordFound = $range.find.execute($findText,$matchCase,    <br \/>$matchWholeWord,$matchWildCards,$matchSoundsLike,    <br \/>$matchAllWordForms,$forward,$wrap)<\/span><\/p>\n<p>It is time to display another status message. If a word is found, the value of the <strong>$wordFound<\/strong> variable was set to <strong>$True<\/strong> by the <strong>Execute<\/strong> method of the <strong>Find<\/strong> object.<\/p>\n<p>Searching a Microsoft Word document by using the <strong>Find<\/strong> object was covered in <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2010\/04\/08\/hey-scripting-guy-april-8-2010.aspx\">an April Hey, Scripting Guy! Blog post<\/a>. In addition to interesting content, there is an excellent picture of a Green Moray eel that I took while scuba diving in Boca Raton, Florida. <\/p>\n<p>If the style of the text that was located is normal, I want to add a hyperlink. If the text is not normal&mdash;for example, if it is a heading or a code style&mdash;I do not want to insert a hyperlink. The <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb245239(v=office.12).aspx\">Hyperlinks object<\/a> is used to work with hyperlinks in a Microsoft Word document.<\/p>\n<p>Inserting hyperlinks into a Microsoft Word document was discussed in <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2009\/05\/11\/how-can-i-convert-a-vbscript-to-a-windows-powershell-script-that-creates-an-office-word-document-with-hyperlinks.aspx\">a May 2009 Hey, Scripting Guy! Blog post<\/a>. Interestingly enough, that article has a really cool picture of a green moray eel that I took while scuba diving off Kona on the Big Island of Hawaii. <\/p>\n<p>To insert a hyperlink, use the <strong>Hyperlinks<\/strong> object&rsquo;s <strong>Add<\/strong> method. This section of the script is shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">Write-Verbose -Message &#8220;$($findText) returned $wordFound&#8221;   <br \/>if($wordFound)     <br \/>{    <br \/>if($Range.style.namelocal -eq &#8220;normal&#8221;)    <br \/>{$null = $document.HyperLinks.Add($Range, $word.URL,$null,$null,$FindText)}<\/span><\/p>\n<p>When text is not normal text style, a verbose message is used to state the style of the text and the fact that the hyperlink was not added. This is shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">ELSE   <br \/>{    <br \/>Write-Verbose -Message `    <br \/>&#8220;$($findText) not modified because it is $($Range.style.namelocal)&#8221;    <br \/>}    <br \/>} #end if $wordFound<\/span><\/p>\n<p>After working with the hyperlink, it is time to reset the Range object to the contents of the document. The start position of the Range object is moved to the start of the range, and the <strong>$wordFound<\/strong> variable is set to <strong>$false<\/strong>. The script will then loop around to the next word in the array. This section of the script is shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">$range = $document.content   <br \/>$null = $range.movestart($wdunits::wdword,$range.start)    <br \/>$wordFound = $false    <br \/>} #end foreach $word<\/span><\/p>\n<p>After all the words from the wordlist.csv file have been processed, it is time to save the document and to close. The code that performs these two operations is shown here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">$document.save()   <br \/>$document.close()    <br \/>} #end foreach $doc<\/span><\/p>\n<p>When all of the documents have been processed, it is time to release the resources. This was talked about in <a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2010\/06\/22\/hey-scripting-guy-how-can-i-use-windows-powershell-2-0-to-convert-doc-files-to-docx-files.aspx\">Tuesday&rsquo;s Hey Scripting Guy Blog post<\/a> and will not be repeated here:<\/p>\n<p><span style=\"background-color: #e6e6e6\">$application.quit()   <br \/>Remove-Variable -Name application    <br \/>[gc]::collect()    <br \/>[gc]::WaitForPendingFinalizers()<\/span><\/p>\n<p>When the script has finished processing a document, the hyperlinks that were added appear as shown in the following image.<\/p>\n<p><a href=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/hsg\/2010\/june\/hey0623\/hsg-06-24-10-04.jpg\"><img decoding=\"async\" height=\"426\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8816.hsg062410042_66886413.jpg\" alt=\"Image of document with added hyperlinks\" border=\"0\" title=\"Image of document with added hyperlinks\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" \/> <\/a><\/p>\n<p>EW, that is all there is to using Windows PowerShell 2.0 to add hyperlinks to a Microsoft Word document. This also concludes our articles for Microsoft Office Week (well, ok, it turned out to be Microsoft Word week). Join us tomorrow when we dig into the virtual mailbag for Quick-Hits Friday&mdash;I have selected some awesome topics. <\/p>\n<p>If you want to know exactly what we will be looking at tomorrow, follow us on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> or <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send e-mail to us at <a href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/strong><\/p>\n<p><strong><br \/><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Hey, Scripting Guy! I need to add hyperlinks to a document by using Windows PowerShell. But I do not want to add hyperlinks to objects that are set in a code style or a heading style. I only want to add the hyperlink to the word if it is in a normal Microsoft Word [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[84,49,3,45],"class_list":["post-17961","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-microsoft-word","tag-office","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>&nbsp; Hey, Scripting Guy! I need to add hyperlinks to a document by using Windows PowerShell. But I do not want to add hyperlinks to objects that are set in a code style or a heading style. I only want to add the hyperlink to the word if it is in a normal Microsoft Word [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/17961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=17961"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/17961\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=17961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=17961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=17961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}