![]() |
#1
|
|||
|
|||
![]()
Greetings,
I am having trouble with "^13" in a wild card macro with which I am working. I am applying the macro to search through text that has - scattered throughout - collections of numbers that are separated by two dashes, e.g., "4-5-708". These patterns in the text are not identical; in other words, within a single record, I may find "55-1-1" as well as "55-11-111", as well as "5-1-111", and so on. I am interested in highlighting each collection of numbers, if any, that begins a paragraph of text. Here is a brief snippet from the macro that is supposed to look for, e.g., "4-5-201" at the beginning of a text paragraph, highlight it, and add bold font to it: Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Font.Bold = True Selection.Find.Replacement.Highlight = True With Selection.Find .Text = "^13[0-9]-[0-9]-[0-9]{2,3}" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = True .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll My difficulty is that the foregoing does not work; it should, but it does not. I believe the culprit is "^13", but I am unable to find a working equivalent or work-around. When I search the record for "[0-9]-[0-9]-[0-9]{2,3}", I get results, but this search is not confined only to patterns that lead a paragraph of the content. When I wild-card-search the record for "^13", I also get results; indeed, Word appears to land upon the hard returns that precede the number patterns of interest. When I make use of "^p" and a literal number that I know is in the text (e.g., "4-5-790"), I also get results. When, however, I undertake to use "^13[0-9]-[0-9]-[0-9]{2,3}", Word finds nothing in the record. That is odd to me, but perhaps I am missing something. I appreciate your attention and hope you may have suggestions. Regards, q. |
Tags |
macros don't work, word 2007 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to use wild card in VBA for Advance Filter? | LearnerExcel | Excel Programming | 1 | 10-09-2017 12:27 AM |
![]() |
sylvio | Word VBA | 2 | 09-04-2017 01:00 AM |
![]() |
catherineliang | Word | 1 | 07-21-2014 09:42 PM |
Wild card to highlight capitalised terms? | bertietheblue | Word | 2 | 02-08-2013 04:44 PM |
![]() |
RichardP | Word VBA | 6 | 04-26-2012 04:22 AM |