View Single Post
 
Old 11-28-2015, 03:12 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 Find whether string contains hyperlink and Process the same

As part of long process, I want to find following string:

Code:
EP [0-9]{5,} [0-9A-Z]{1,2}
and if it contains hyperlink i would like to use that link to process it for winhttp request like this.
if in doc, there is
EP 2614045 B1 with hyperlink https://data.epo.org/publication-ser...45&ki=B1&lg=en

Code:
Sub EPHYPERLINKDOWN()
Dim myURL As String, s As String, s1 As String, StrTxt As String
myURL = "https://data.epo.org/publication-server/document?cc=EP&pn=2614045&ki=B1&lg=en"

Dim HttpReq As Object, oStrm As Object
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 want to remove original hyperlink with MsgBox Hyperlink.

So, I learned middle part but don't know how to run first part and last one.
Reply With Quote