Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-20-2019, 04:36 AM
MikeForward MikeForward is offline Word VBA wildcard search - odd results Windows 10 Word VBA wildcard search - odd results Office 2010
Novice
Word VBA wildcard search - odd results
 
Join Date: Feb 2019
Posts: 10
MikeForward is on a distinguished road
Default Word VBA wildcard search - odd results

Hi there,



I am finding odd results with the following wildcard search in Word 2010 VBA. I am trying to search for special codewords embedded in a Word doc which look like "ZXZABCDEF...". where X is a single character which can be 0-9,A-Z, as are the ABCDEF.... The first and third characters are always Z. The ABCDEF...is a minimum of 3 characters and a maximum of 16 characters.

The following search works correctly in either backwards or forwards direction:
[/code] Selection.Find.ClearFormatting
With Selection.Find
.Text = "<Z[0-9A-Z]Z[0-9A-Z]{3}"
.Replacement.Text = ""
.Forward = bForwards '***where bForwards is a Boolean = true or false
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
b = Selection.Find.Execute[/code]

However, if I change the {3} in the .Text= line to {3,16} the search then works forwards, but fails backwards! Any ideas? Macropod - this is a simplified form of my first question, and does seem to give genuinely odd results. I promise no more questions for a while after this!

Thanks a lot

Mike
Reply With Quote
 

Tags
wildcard searches



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word VBA wildcard search - odd results Having problems with a Wildcard search Cosmo Word VBA 9 02-12-2016 08:03 PM
Change characters outside a wildcard while keeping wildcard results nymusicman Word VBA 2 04-10-2014 08:17 AM
2013 search results take a long time - they fill in as results in reverse date order themookman Outlook 0 10-11-2013 12:01 PM
Word VBA wildcard search - odd results Saving search results in word 2010 swami Word 2 09-04-2013 11:34 PM
Wildcard search help. Kempston Word 0 11-13-2009 03:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:19 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