Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 01-03-2022, 10:45 PM
gmayor's Avatar
gmayor gmayor is offline Convert Folder paths to Hyperlinks Windows 10 Convert Folder paths to Hyperlinks Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,143
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Folder paths to Hyperlinks Convert many hyperlinks to the actual url, document-wide, not individually enso Word VBA 4 02-25-2021 05:19 PM
Convert Folder paths to Hyperlinks Convert html links into embedded hyperlinks 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft