View Single Post
 
Old Today, 03:44 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,628
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Quote:
Originally Posted by RobiNew View Post
Obviously I was referring to gmaxey's code, which contains "Do While .Find.Execute".
The first part of your code returns ".Execute" Not valid!!
The second part ("http://[! ]{1,}") doesn't find anything at all.
Up to now the only working code is the one I posted, though unfortunately it returns only "http://w", not the whole inactive link.

Robinew,


I have to agree with Paul. I have tried every way that I can think of to break Paul's code or mine in such a way it returns the error your report. I just doesn't happen or make sense. Regardless, here is a version of your original code that you can try:

Code:
Sub SelectNextURL()
Dim oDoc As Document, oRng As Range
  Set oDoc = ActiveDocument
  Set oRng = oDoc.Range
  With oRng.Find
    .ClearFormatting
    .Text = ""
    .MatchWildcards = True
    'Word wildcards: http[s]:// followed by any non-space characters
    .Text = "(http*)(://*)([! ^13^32^9^t<>'""]{1,})"
    If .Execute Then
      oRng.Select
      MsgBox "URL found and selected: " & oRng.Text, vbInformation
    Else
      MsgBox "No URL found.", vbExclamation
    End If
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote