I think I am not good at explaining. That paid off. allowed me to try on my own. I found bit of solution by browsing my earlier Ques.
I recorded macro and then used solution from post to yield following solution.
Code:
Sub EPHYPERLINKDOWN()
Dim myURL As String, s As String, s1 As String, StrTxt As String
Dim HttpReq As Object, oStrm As Object
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
Do While .Execute(FindText:="EP [0-9]{5,} [0-9A-Z]{1,2}", MatchWildcards:=True)
If Selection.Hyperlinks.Count > 0 Then
s = Selection.Hyperlinks(1).Name
End If
Loop
End With
MsgBox (s)
myURL = s
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
HttpReq.Open "GET", myURL, False
HttpReq.send
s = HttpReq.responseText
Set HttpReq = Nothing
Set DocNew = Documents.Add
With DocNew
.Range.Text = s
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
.Text = "https://data.epo.org/publication-server/pdf-document*.pdf*.pdf"
.Replacement.Text = ""
.Execute
End With
s1 = Replace(.Text, "amp;", "")
End With
.Close
Set DocNew = Nothing
Application.ScreenUpdating = True
MsgBox (s1)
End With
End Sub
I think there is problem with loop in second part. Please suggest
Its not looping through all instances
Other problem with this code here is that I want to remove original hyperlink with what I get here as s1 at last (I use msgbox to see weather code is working or not).
file