TechWhirl (TECHWR-L) is a resource for technical writing and technical communications professionals of all experience levels and in all industries to share their experiences and acquire information.
For two decades, technical communicators have turned to TechWhirl to ask and answer questions about the always-changing world of technical communications, such as tools, skills, career paths, methodologies, and emerging industries. The TechWhirl Archives and magazine, created for, by and about technical writers, offer a wealth of knowledge to everyone with an interest in any aspect of technical communications.
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