RE: Finding character styles in Word with VBA

Subject: RE: Finding character styles in Word with VBA
From: "Jonathan West" <jwest -at- mvps -dot- org>
To: <techwr-l -at- lists -dot- techwr-l -dot- com>
Date: Thu, 23 Mar 2006 12:10:42 -0000


>
> Hmmmm... I've tried using wildcards, and I've tried using nothing in the
> quotes. The char styles aren't picked up. You can test it yourself. It's
> not just that they don't work in a macro, but using Find and replace
> doesn't find them, and yet it will find a para style of the same name
> and will find characteristics of the style such as colour or weight.
>
> It's a conundrum.


Set the Format property of the Find object to True.

Before assigning any other properties, ensure that you use the
ClearFormatting method to get rid of any past settings.

Like this.

For i = 0 To 8
With Selection.Find
.ClearFormatting
.Format = True
.Style = ActiveDocument.styles(mystyles(i))
.Replacement.ClearFormatting
.Replacement.Style = ActiveDocument.styles(replacementstyles(i))
.Text = ""
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
Next i

Regards
Jonathan

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.2.6/288 - Release Date: 22/03/2006

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

WebWorks ePublisher Pro for Word features support for every major Help
format plus PDF, HTML and more. Flexible, precise, and efficient content
delivery. Try it today!. http://www.webworks.com/techwr-l

Doc-To-Help includes a one-click RoboHelp project converter. It's that easy. Watch the demo at http://www.componentone.com/TECHWRL/DocToHelp2005

---
You are currently subscribed to TECHWR-L as archive -at- infoinfocus -dot- com -dot-

To unsubscribe send a blank email to
techwr-l-unsubscribe -at- lists -dot- techwr-l -dot- com
or visit http://lists.techwr-l.com/mailman/options/techwr-l/archive%40infoinfocus.com

To subscribe, send a blank email to techwr-l-join -at- lists -dot- techwr-l -dot- com

Send administrative questions to lisa -at- techwr-l -dot- com -dot- Visit
http://www.techwr-l.com/techwhirl/ for more resources and info.


References:
RE: Finding character styles in Word with VBA: From: Partridge, Robert

Previous by Author: RE: Wanted: Any available doc comparing Word XP and FrameMaker 7.2
Next by Author: RE: Any suggestions for replacing Word
Previous by Thread: RE: Finding character styles in Word with VBA
Next by Thread: RE: Finding character styles in Word with VBA


What this post helpful? Share it with friends and colleagues:


Sponsored Ads