Group: microsoft.public.word.vba.general
From: IdontWantSpam@nospam.net (Edward Thrashcort)
Date: Tuesday, October 23, 2007 3:34 PM
Subject: Re: Macro Find and Replace with styles

I remember having a similar problem which I had to kludge my way around.
The trouble is that the (*) part of the search text can be ANYTHING
including the whole document!


Something like this

- find first tag
Do while found
- delete selection
- get the range end position of the cursor "a"
- find closing tag
- get the range start "b"
- delete the selection
- select the range between (a+1) abd (b-1)
- reformat
- find first tag
loop

Eddie


> *From:* Chris
> *Date:* Wed, 22 Aug 2007 01:32:02 -0700
>
> Hi,
>
> i have a macro which formats the text between Html-Tags like Text
> with standard header styles. The problem is that my whole document will
> be replaced with this format style. But i only want to format the text
> between the HTML-Tags.
> Her is my snippet:
>
> With ActiveDocument.Range.Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Format = True
> .MatchWildcards = True
> .Text = "(\)(*)(\)"
> .Replacement.Text = "\2"
> .Replacement.Style =
> ActiveDocument.Styles(WdBuiltinStyle.wdStyleHeading1)
> .Execute Replace:=wdReplaceAll
> End With
>
> Many thanks for any advice...
>
> Chris
>