View Single Post
 
Old 11-29-2015, 09:33 AM
PRA007's Avatar
PRA007 PRA007 is offline Windows 7 64bit Office 2010 32bit
Competent Performer
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

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
Attached Files
File Type: docx EP 2614045 B1.docx (10.7 KB, 11 views)
Reply With Quote