atw: Finding character styles in Word with VBA
- From: "Partridge, Robert" <Robert.Partridge@xxxxxxxxxxxxx>
- To: <austechwriter@xxxxxxxxxxxxx>
- Date: Wed, 22 Mar 2006 10:20:06 +1100
Hi guys,
I'm trying to find both para and char formats and replace them with
other formats in Word XP. I've got an array of the find styles and
another of the replace styles. Finding and replacing para formats is
easy with this code:
For i = 0 To 8
Selection.Find.Style = ActiveDocument.styles(styles(i))
Selection.Find.Replacement.Style =
ActiveDocument.styles(replacementstyles(i))
With Selection.Find
.Text = "^p"
.Replacement.Text = "^p"
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next i
What I can't seem to do is find character styles using the same method.
So I've got a sentence like:
[style a]Something here [style b] and some more text in here[end style
b] and back to the original style.[end style a]
Is there any way to find style b and replace with style a with vba? I
tried using empty find and replace strings or using find any character
(^?) and replace with the find text (^&) but they don't work.
Cheers,
Rob
Other related posts:
- » atw: Finding character styles in Word with VBA