Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old Today, 09:36 AM
gmaxey gmaxey is offline Find and select a passive URL string Windows 10 Find and select a passive URL string Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,629
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
Many thanks, gmaxey! Your code returns an error on "bFound = .Execute"
and the message reads:
Run-time error '5560'
The Find What text contains an invalid expression.
Use search criteria

Robinew,


I suspect that is because of where you live (or your regional settings). Try:


Code:
Sub SelectNextURL()
Dim oDoc As Document, oRng As Range
Dim bFound As Boolean
Dim strLS As String
  strLS = Application.International(wdListSeparator)
  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" & strLS & "})"
    bFound = .Execute
  End With
  If bFound Then
    oRng.Select
    MsgBox "URL found and selected: " & oRng.Text, vbInformation
  Else
    MsgBox "No URL found.", vbExclamation
  End If
lbl_Exit:
  Exit Sub
End Sub
or simplified:


Code:
Sub SelectNextURL()
Dim oDoc As Document, oRng As Range
Dim strLS As String
  strLS = Application.International(wdListSeparator)
  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" & strLS & "})"
    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
  #17  
Old Today, 10:28 AM
RobiNew RobiNew is offline Find and select a passive URL string Windows 11 Find and select a passive URL string Office 2016
Competent Performer
Find and select a passive URL string
 
Join Date: Sep 2023
Posts: 219
RobiNew is on a distinguished road
Default

That's great! Thank you, gmaxey. Your simplified version works perfectly. I thought we'd never find a solution. All the best!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find string, Replace with dot tab dhapp Word 5 03-27-2023 07:23 AM
Find and select all string of simlar pattern anon123 Word 4 04-20-2016 11:41 PM
How to find all string within string. PRA007 Word VBA 18 02-12-2016 08:11 PM
Find and select a passive URL string Why is this Find string not working TechEd Word VBA 5 07-05-2014 08:12 PM
Find and select a passive URL string Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft