![]() |
#3
|
||||
|
||||
![]()
If each item in the list is a paragraph then select the list and run the following Word macro. This will hyperlink those paragraphs that have valid folder paths. Invalid paths are coloured red.
Code:
Sub Macro1() 'Graham Mayor - https://www.gmayor.com - Last updated - 04 Jan 2022 Dim sLink As String Dim oLink As Hyperlink Dim oPara As Paragraph Dim oRng As Range Dim FSO As Object Set FSO = CreateObject("Scripting.FileSystemObject") For Each oPara In Selection.Paragraphs Set oRng = oPara.Range oRng.End = oRng.End - 1 If FSO.FolderExists(oRng.Text) Then Set oLink = Selection.Hyperlinks.Add(Anchor:=oRng, _ Address:=oRng.Text, _ ScreenTip:="Click to select the linked folder", _ TextToDisplay:=oRng.Text) Else oRng.Font.ColorIndex = wdRed End If Next oPara lbl_Exit: Set oLink = Nothing Set oRng = Nothing Set oPara = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
enso | Word VBA | 4 | 02-25-2021 05:19 PM |
![]() |
njcloud | Mail Merge | 23 | 02-04-2020 02:00 PM |
Network Paths not formatting as hyperlinks | kneghx | Outlook | 0 | 10-11-2018 11:10 AM |
Convert Hyperlinks to ahref | dan88 | Word VBA | 2 | 05-09-2016 06:19 PM |
Macro to change/convert/delete txt files in folder+subfolders | NoS | Word VBA | 4 | 03-03-2016 12:10 PM |