View Single Post
 
Old 11-29-2015, 10:41 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub EPHYPERLINKDOWN()
Application.ScreenUpdating = False
Dim StrTxt As String, HttpReq As Object, i As Long
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "EP [0-9]{5,} [0-9A-Z]{1,2}"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    If .Hyperlinks.Count > 0 Then
      HttpReq.Open "GET", .Hyperlinks(1).Name, False
      HttpReq.Send
      StrTxt = HttpReq.ResponseText
      i = InStr(StrTxt, "https://data.epo.org/publication-server/pdf-document")
      StrTxt = Mid(StrTxt, i, Len(StrTxt) - i)
      i = InStr(InStr(StrTxt, ".pdf") + 3, StrTxt, ".pdf")
      StrTxt = Replace(Left(StrTxt, i + 3), "amp;", "")
      .Hyperlinks(1).Address = StrTxt
    End If
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Set HttpReq = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote