I'm trying to list the multiple hyperlinks in a Word 2016 document in a .txt file. To be more specific, I'm trying to list the 36th character from the left to the 75th character of each hyperlink. The code below is close, because I did have it working earlier, but for some reason I must have changed something without realizing it. Anyone help pls?
Code:
Dim fso As FileSystemObject ' Declare a FileSystemObject.
Dim stream As TextStream ' Declare a TextStream.
Sub ListHyperlinks()
Dim i As Integer
Dim Rng As Range
Dim strMid As String
Set fso = New FileSystemObject ' Create a FileSystemObject.
Set stream = fso.CreateTextFile("C:\Test1.txt", True)
Application.ScreenUpdating = False
With ActiveDocument
For i = .Hyperlinks.Count To 1 Step -1
With .Hyperlinks(i)
Set Rng = .Range
strMid = Mid(Rng, 36, 75)
stream.WriteLine (strMid)
End With
Next
End With
' Close the file.
stream.Close
Application.ScreenUpdating = True
End Sub
I should add: when I step through the code above I get Rng = "" and srtMid = "" , the rectangle shape has now taken the place of the text I used to get