I have text styled with a custom character style. Some of that text also has
direct formatting applied (bold, ital, etc.).

I need to remove the character style, but retain the direct formatting.

Possibly I also need to retain any font formatting provided by the style as.

I can do this:

For Each c In Selection.Characters
Set f = c.Font.Duplicate
c.Font.Reset
c.Font = f
Next c

but this is slow and I keep thinking I'm missing a simpler, faster way to do
this. Any suggestions?

Re: Remove character style with direct formatting by Helmut

Helmut
Wed Sep 12 15:38:18 CDT 2007

Hi,

like this:

Sub Test7()
Dim aStl As Style
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
For Each aStl In ActiveDocument.Styles
If aStl.Type = 2 Then
With ActiveDocument.Range.Find
.Style = aStl
While .Execute
rDcm.Font.Reset
Wend
End With
End If
Next

End Sub

Search for character-styles only,
that is style.type = 2,
while found
reset

There are other ways as well.


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Re: Remove character style with direct formatting by m

m
Thu Sep 13 07:22:07 CDT 2007

Unfortuneately, all this does is reset the font formatting of the styled
text. I need to retain any direct formatting.

"Helmut Weber" <nbhymsjxdgcn@mailinator.com> wrote in message
news:bdjge3li18kbnn76n1uvh2n9kin4hvflek@4ax.com...
> Hi,
>
> like this:
>
> Sub Test7()
> Dim aStl As Style
> Dim rDcm As Range
> Set rDcm = ActiveDocument.Range
> For Each aStl In ActiveDocument.Styles
> If aStl.Type = 2 Then
> With ActiveDocument.Range.Find
> .Style = aStl
> While .Execute
> rDcm.Font.Reset
> Wend
> End With
> End If
> Next
>
> End Sub
>
> Search for character-styles only,
> that is style.type = 2,
> while found
> reset
>
> There are other ways as well.
>
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"



Re: Remove character style with direct formatting by Helmut

Helmut
Thu Sep 13 09:23:13 CDT 2007

Hi Rafala,

i hadn't quite got what you wanted to do.

Maybe, if you don't need the particular character style any longer,
deleting it from the doc would help you.

Sub Test7()
Dim aStl As Style
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
For Each aStl In ActiveDocument.Styles
If aStl.Type = wdStyleTypeCharacter And _
aStl <> "Default Paragraph Font" Then
With rDcm.Find
.Style = aStl
While .Execute
rDcm.Select ' for testing
Stop ' for testing
ActiveDocument.Styles(aStl).Delete
Wend
End With
End If
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Re: Remove character style with direct formatting by m

m
Thu Sep 13 10:22:11 CDT 2007

Ah. Excellent. I didn't think of that.

This does indeed retain the direct formatting. I do loose the formatting
that's build into the style (such as bold), but I can reapply that if needed
after deleting the style. thanks.


"Helmut Weber" <nbhymsjxdgcn@mailinator.com> wrote in message
news:6hhie3dj7iru57v0olj02noek4ch2qkckt@4ax.com...
> Hi Rafala,
>
> i hadn't quite got what you wanted to do.
>
> Maybe, if you don't need the particular character style any longer,
> deleting it from the doc would help you.
>
> Sub Test7()
> Dim aStl As Style
> Dim rDcm As Range
> Set rDcm = ActiveDocument.Range
> For Each aStl In ActiveDocument.Styles
> If aStl.Type = wdStyleTypeCharacter And _
> aStl <> "Default Paragraph Font" Then
> With rDcm.Find
> .Style = aStl
> While .Execute
> rDcm.Select ' for testing
> Stop ' for testing
> ActiveDocument.Styles(aStl).Delete
> Wend
> End With
> End If
> Next
> End Sub
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"