Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 10-17-2019, 08:56 PM
gmayor's Avatar
gmayor gmayor is offline Extract Path in quotes and insert it into text Windows 10 Extract Path in quotes and insert it into text Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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

You can't have hyperlinks in a text file, but you can in a Word document. Assuming that you example is a fair representation call the following macro from a loop to open your documents
Code:
Sub AddLinks(oDoc As Document)
Dim oPara As Paragraph
Dim oRng As Range
Dim vPara As Variant
Dim strLink As String
Dim strDisplay As String
Dim lngPara As Long

    For Each oPara In oDoc.Paragraphs
        Set oRng = oPara.Range
        oRng.End = oRng.End - 1
        If InStr(1, oRng.Text, "C:\") > 1 Then
            vPara = Split(oRng.Text, Chr(34))
            strDisplay = Trim(vPara(0))
            strLink = Trim(Replace(vPara(1), Chr(34), ""))
            oRng.Text = ""
            oRng.Hyperlinks.Add Anchor:=oRng, Address:=strLink, TextToDisplay:=strDisplay
        End If
    Next oPara
lbl_Exit:
    Set oPara = Nothing
    Set oRng = 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
 

Tags
link hyperlink filename



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract Path in quotes and insert it into text Insert variable in path name bearcublandon Word VBA 6 01-03-2019 08:17 PM
Extract Path in quotes and insert it into text How to replace straight quotes with smart quotes in existing document PABwriter Word 4 05-27-2016 03:36 PM
Changing dumb quotes to smart quotes Reisende Word 2 05-02-2016 08:56 PM
Extract Path in quotes and insert it into text insert auto path & file name in ppt 2013 rideninc PowerPoint 1 01-28-2014 05:38 AM
Extract Path in quotes and insert it into text Changing single-quotes to double-quotes Bobosmite Word 5 04-15-2013 06:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:19 PM.


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