Re: Selection using Wildcards



Thanks Greg I'll no go and examine the Help file to understand the meaning
of "[0-9]{1,}" particularly "{1,}" part

However in my example, I used numerals just to make the problem clearer.
In reality the font that I'm searching-for could contain ANYTHING, maybe
even pictures, tables and stuff.

Eddie

*From:* "Greg Maxey" <gmaxey@xxxxxxxxx>
*Date:* 23 Mar 2007 12:23:49 -0700

Try:
Sub Scratchmacro()
Dim oRng As Word.Range
Set oRng = Selection.Range 'or ActiveDocument.Range
With oRng.Find
.Text = "[0-9]{1,}"
.MatchWildcards = True
.Wrap = wdFindContinue
.Style = ActiveDocument.Styles("Numeral Font")
.Replacement.Text = "PREFIX^&SUFFIX"
.Execute Replace:=wdReplaceAll
End With
End Sub

On Mar 23, 2:51 pm, IdontWantS...@xxxxxxxxxx (Edward Thrashcort)
wrote:
I'm trying to select all the phrases in a document that are written in a
particular character style and replace them with a PREFIX followed by a
SUFFIX. So let's assume that I have specified a character font for
numerals and assigned it only to the numbers in the following range...

abc 123 xyz 999 pqr

it would be replaced with

abc PREFIX123456SUFFIX wxy PREFIX999SUFFIX pqr

With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.Forward = True
.Wrap = wdFindContinue

.Style = ActiveDocument.Styles("Numeral Font")
.Text = "(*)"
.Replacement.Text = "PREFIX\1SUFFIX"

'For testing I'll replace both separately
'The code should be .Execute Replace:=wdReplaceAll

.Execute Replace:=wdReplaceOne
.Execute Replace:=wdReplaceOne
End With

Unfortunately this code only selects the FIRST character then the SECOND
character - not the first phrase and the second phrase

I've also tried
.Text = "(*@)"
.Text = "(?@)"
I've tried
.Format = False
.Format = True (not quite sure what this means anyway!)

but nothing works!

Am I trying to do something that "wildcards" is not capable of
performing?

Eddie




.



Relevant Pages

  • Re: txt-file is in ANSI format or OEM Character format.
    ... Try 2 and 3 above changing formating to a different Font. ... This file I open in UltraEdit and change ANSI to OEM and close ... The older printers have a smaller character set it ... Character format. ...
    (microsoft.public.excel.programming)
  • Re: how put in a superscript number
    ... Select the character you want to superscript and choose Format menu => Font ...
    (microsoft.public.mac.office.word)
  • Re: Convert text with special characters
    ... > Are you saying you could format the font character by character in one of the ... I did not mean that I could format font to font. ... import/export text with special characters and could not get it to work. ...
    (microsoft.public.excel.programming)
  • Re: Styles - Creating opening paragraph with dropcap
    ... rest of the paragraph wraps around and underneath it nicely. ... style called FirstChar and set the Style Type to Character. ... Format, Font, set the font size and then choose the Character Spacing ...
    (microsoft.public.word.general)
  • Re: English versus German
    ... assigning keyboard shortcuts, or any of that other fancy stuff. ... get an acute accent over "a" in Word, and I've modified my keyboard to ... I don't know of a simple way to get both accents on the same character ... Then you need to update your font. ...
    (sci.lang)