Macro to Remove Direct Font Name without Removing other font properties

J

Julie

Hello,

I am writing macros to clean up converted WordPerfect documents and am
stumped trying to figure out how to find and remove directly applied font
names without,

- removing any other directly applied font formatting (size, bold, italic,
etc.), and
- without breaking the ability to later change the font of the underlying
style and have that change take effect for all paragraphs styled with that
style

(I don't know the name of the font to search for up front - could be any
font - always know the name of the font to apply in replacement - that is
the default paragraph font name).

Every method I try has its pitfalls (Word2000), including find each style
and replace each style with "no formatting", apply the underling paragraph
font to the paragraph, etc.

Final result must be that after macro finishes, if user changes the font of
the underlying style, the change takes effect for all paragraphs with that
style. All of the methods that I have tried are successful in applying the
correct font, but they break the ability to make subsequent font changes to
the underlying paragraph style and have those changes take effect for all
relevant paragraphs.

Formerly, in WordPerfect, I was able to achieve this end with a very simple
macro to find [Font] codes and replace with nothing.

Any help with this would be very much appreciated.

Thanks in advance,
Julie
 
P

Peter Hewett

Hi Julie

Iterate the documents Paragraph collection (use a For Each loop). Look up the
paragraphs style, look up the styles font name and then apply the font name ass
direct formatting.

HTH + Cheers - Peter
 
J

Julie

Hi Peter.

Thanks for the reply. The method you suggested has been tried and it causes
one of the problems mentioned in my first post, e.g. this code

Sub testit()

Dim opara As Paragraph
Dim oSty As Style

For Each opara In ActiveDocument.Paragraphs
Set oSty = ActiveDocument.Styles(opara.Style)

opara.Range.Font.Name = oSty.Font.Name

Next opara

Set opara = Nothing
Set oSty = Nothing
End Sub


If I run this in Word2000 fully patched running under Windows XP, it does
the job, but .... if LATER I edit the font property of the underlying style,
I am afflicted with the very problem I am trying to resolve. If I try the
code out on some paragraphs styled with Normal, with Normal style currently
set to Arial (but paragraphs manually formtted with TNR), the macro does
what it should - that is apply Arial to all. Later, If I edit Normal style
to change the font to TNR, all of the directly-applied Arial remains - thus,
now my whole document has a direct font applied rather than just part of it.

Am I missing something here????

Thanks,
Julie

Peter Hewett said:
Hi Julie

Iterate the documents Paragraph collection (use a For Each loop). Look up the
paragraphs style, look up the styles font name and then apply the font name ass
direct formatting.

HTH + Cheers - Peter


Hello,

I am writing macros to clean up converted WordPerfect documents and am
stumped trying to figure out how to find and remove directly applied font
names without,

- removing any other directly applied font formatting (size, bold, italic,
etc.), and
- without breaking the ability to later change the font of the underlying
style and have that change take effect for all paragraphs styled with that
style

(I don't know the name of the font to search for up front - could be any
font - always know the name of the font to apply in replacement - that is
the default paragraph font name).

Every method I try has its pitfalls (Word2000), including find each style
and replace each style with "no formatting", apply the underling paragraph
font to the paragraph, etc.

Final result must be that after macro finishes, if user changes the font of
the underlying style, the change takes effect for all paragraphs with that
style. All of the methods that I have tried are successful in applying the
correct font, but they break the ability to make subsequent font changes to
the underlying paragraph style and have those changes take effect for all
relevant paragraphs.

Formerly, in WordPerfect, I was able to achieve this end with a very simple
macro to find [Font] codes and replace with nothing.

Any help with this would be very much appreciated.

Thanks in advance,
Julie
 
P

Peter Hewett

Hi Julie

Nope, you're on target. Once you apply direct formatting you either live with
it or remove it! Direct formatting always overrides the style defaults.
Generally you want the directly applied formatting to stick when you update the
style(s). Even character styles don't solve the problem as they're removed if
you do a ".Font.Reset".

As you've discovered resetting the font changes all of the font attributes back
to the style default, not just the font name.

Cheers - Peter :(

Hi Peter.

Thanks for the reply. The method you suggested has been tried and it causes
one of the problems mentioned in my first post, e.g. this code

Sub testit()

Dim opara As Paragraph
Dim oSty As Style

For Each opara In ActiveDocument.Paragraphs
Set oSty = ActiveDocument.Styles(opara.Style)

opara.Range.Font.Name = oSty.Font.Name

Next opara

Set opara = Nothing
Set oSty = Nothing
End Sub


If I run this in Word2000 fully patched running under Windows XP, it does
the job, but .... if LATER I edit the font property of the underlying style,
I am afflicted with the very problem I am trying to resolve. If I try the
code out on some paragraphs styled with Normal, with Normal style currently
set to Arial (but paragraphs manually formtted with TNR), the macro does
what it should - that is apply Arial to all. Later, If I edit Normal style
to change the font to TNR, all of the directly-applied Arial remains - thus,
now my whole document has a direct font applied rather than just part of it.

Am I missing something here????

Thanks,
Julie

Peter Hewett said:
Hi Julie

Iterate the documents Paragraph collection (use a For Each loop). Look up the
paragraphs style, look up the styles font name and then apply the font name ass
direct formatting.

HTH + Cheers - Peter


Hello,

I am writing macros to clean up converted WordPerfect documents and am
stumped trying to figure out how to find and remove directly applied font
names without,

- removing any other directly applied font formatting (size, bold, italic,
etc.), and
- without breaking the ability to later change the font of the underlying
style and have that change take effect for all paragraphs styled with that
style

(I don't know the name of the font to search for up front - could be any
font - always know the name of the font to apply in replacement - that is
the default paragraph font name).

Every method I try has its pitfalls (Word2000), including find each style
and replace each style with "no formatting", apply the underling paragraph
font to the paragraph, etc.

Final result must be that after macro finishes, if user changes the font of
the underlying style, the change takes effect for all paragraphs with that
style. All of the methods that I have tried are successful in applying the
correct font, but they break the ability to make subsequent font changes to
the underlying paragraph style and have those changes take effect for all
relevant paragraphs.

Formerly, in WordPerfect, I was able to achieve this end with a very simple
macro to find [Font] codes and replace with nothing.

Any help with this would be very much appreciated.

Thanks in advance,
Julie

HTH + Cheers - Peter
 
J

Julie

Thanks Peter

How disappointing. My users are accustomed to having a tool to quickly
strip out unwanted font Names and won't be happy to lose it.

I spent the better part of yesterday writing a macro to make the change
character by character . What a pain! It looked on the surface like it
would be a go but the biggest problem I have is accurately identifying a
non-unicode symbol to avoid disrupting the font for the symbol.

Is there a quick test to identify whether a symbol is a candidate for a font
change or whether the font must be left alone for that symbol?

I read a number of threads about finding symbols and evaluating characters
by character number, but don't see anything on point and what I did read
about characters and how Word crunches the numbers for characters is
difficult for someone at my level to understand. I have a range set to
point to a single character at the time that I need to evaluate the
character and would like to be able to identify whether the character in
that range (1) is a symbol, and (2) if so, is it one that requires the font
name stay).

Thanks,
Julie

Peter Hewett said:
Hi Julie

Nope, you're on target. Once you apply direct formatting you either live with
it or remove it! Direct formatting always overrides the style defaults.
Generally you want the directly applied formatting to stick when you update the
style(s). Even character styles don't solve the problem as they're removed if
you do a ".Font.Reset".

As you've discovered resetting the font changes all of the font attributes back
to the style default, not just the font name.

Cheers - Peter :(

Hi Peter.

Thanks for the reply. The method you suggested has been tried and it causes
one of the problems mentioned in my first post, e.g. this code

Sub testit()

Dim opara As Paragraph
Dim oSty As Style

For Each opara In ActiveDocument.Paragraphs
Set oSty = ActiveDocument.Styles(opara.Style)

opara.Range.Font.Name = oSty.Font.Name

Next opara

Set opara = Nothing
Set oSty = Nothing
End Sub


If I run this in Word2000 fully patched running under Windows XP, it does
the job, but .... if LATER I edit the font property of the underlying style,
I am afflicted with the very problem I am trying to resolve. If I try the
code out on some paragraphs styled with Normal, with Normal style currently
set to Arial (but paragraphs manually formtted with TNR), the macro does
what it should - that is apply Arial to all. Later, If I edit Normal style
to change the font to TNR, all of the directly-applied Arial remains - thus,
now my whole document has a direct font applied rather than just part of it.

Am I missing something here????

Thanks,
Julie

Peter Hewett said:
Hi Julie

Iterate the documents Paragraph collection (use a For Each loop). Look
up
the
paragraphs style, look up the styles font name and then apply the font name ass
direct formatting.

HTH + Cheers - Peter


"Julie" <[email protected]>, said:

Hello,

I am writing macros to clean up converted WordPerfect documents and am
stumped trying to figure out how to find and remove directly applied font
names without,

- removing any other directly applied font formatting (size, bold, italic,
etc.), and
- without breaking the ability to later change the font of the underlying
style and have that change take effect for all paragraphs styled with that
style

(I don't know the name of the font to search for up front - could be any
font - always know the name of the font to apply in replacement - that is
the default paragraph font name).

Every method I try has its pitfalls (Word2000), including find each style
and replace each style with "no formatting", apply the underling paragraph
font to the paragraph, etc.

Final result must be that after macro finishes, if user changes the
font
of
the underlying style, the change takes effect for all paragraphs with that
style. All of the methods that I have tried are successful in
applying
the
correct font, but they break the ability to make subsequent font
changes
to
the underlying paragraph style and have those changes take effect for all
relevant paragraphs.

Formerly, in WordPerfect, I was able to achieve this end with a very simple
macro to find [Font] codes and replace with nothing.

Any help with this would be very much appreciated.

Thanks in advance,
Julie

HTH + Cheers - Peter
 
P

Peter Hewett

Hi Julie

I don't believe you can identify all characters in a Word document by their
returned unicode values. The problem is that Word masks characters such as
Symbol, Wingdings etc. If you insert a Wingding character in your document and
ask Word what the font is, it returns the name of the font from either the
paragraph style or from directly applied formatting.

Once you've inserted your Winding character select it and then change it's font
- nothing happens to it's appearance, the font name changes but not the
character!

I can't see a way out, I'll have a think and post back if anything occurs to me.

Cheers + good luck - Peter

Thanks Peter

How disappointing. My users are accustomed to having a tool to quickly
strip out unwanted font Names and won't be happy to lose it.

I spent the better part of yesterday writing a macro to make the change
character by character . What a pain! It looked on the surface like it
would be a go but the biggest problem I have is accurately identifying a
non-unicode symbol to avoid disrupting the font for the symbol.

Is there a quick test to identify whether a symbol is a candidate for a font
change or whether the font must be left alone for that symbol?

I read a number of threads about finding symbols and evaluating characters
by character number, but don't see anything on point and what I did read
about characters and how Word crunches the numbers for characters is
difficult for someone at my level to understand. I have a range set to
point to a single character at the time that I need to evaluate the
character and would like to be able to identify whether the character in
that range (1) is a symbol, and (2) if so, is it one that requires the font
name stay).

Thanks,
Julie

Peter Hewett said:
Hi Julie

Nope, you're on target. Once you apply direct formatting you either live with
it or remove it! Direct formatting always overrides the style defaults.
Generally you want the directly applied formatting to stick when you update the
style(s). Even character styles don't solve the problem as they're removed if
you do a ".Font.Reset".

As you've discovered resetting the font changes all of the font attributes back
to the style default, not just the font name.

Cheers - Peter :(

Hi Peter.

Thanks for the reply. The method you suggested has been tried and it causes
one of the problems mentioned in my first post, e.g. this code

Sub testit()

Dim opara As Paragraph
Dim oSty As Style

For Each opara In ActiveDocument.Paragraphs
Set oSty = ActiveDocument.Styles(opara.Style)

opara.Range.Font.Name = oSty.Font.Name

Next opara

Set opara = Nothing
Set oSty = Nothing
End Sub


If I run this in Word2000 fully patched running under Windows XP, it does
the job, but .... if LATER I edit the font property of the underlying style,
I am afflicted with the very problem I am trying to resolve. If I try the
code out on some paragraphs styled with Normal, with Normal style currently
set to Arial (but paragraphs manually formtted with TNR), the macro does
what it should - that is apply Arial to all. Later, If I edit Normal style
to change the font to TNR, all of the directly-applied Arial remains - thus,
now my whole document has a direct font applied rather than just part of it.

Am I missing something here????

Thanks,
Julie

Hi Julie

Iterate the documents Paragraph collection (use a For Each loop). Look up
the
paragraphs style, look up the styles font name and then apply the font
name ass
direct formatting.

HTH + Cheers - Peter


"Julie" <[email protected]>, said:

Hello,

I am writing macros to clean up converted WordPerfect documents and am
stumped trying to figure out how to find and remove directly applied font
names without,

- removing any other directly applied font formatting (size, bold,
italic,
etc.), and
- without breaking the ability to later change the font of the underlying
style and have that change take effect for all paragraphs styled with
that
style

(I don't know the name of the font to search for up front - could be any
font - always know the name of the font to apply in replacement - that is
the default paragraph font name).

Every method I try has its pitfalls (Word2000), including find each style
and replace each style with "no formatting", apply the underling
paragraph
font to the paragraph, etc.

Final result must be that after macro finishes, if user changes the font
of
the underlying style, the change takes effect for all paragraphs with
that
style. All of the methods that I have tried are successful in applying
the
correct font, but they break the ability to make subsequent font changes
to
the underlying paragraph style and have those changes take effect for all
relevant paragraphs.

Formerly, in WordPerfect, I was able to achieve this end with a very
simple
macro to find [Font] codes and replace with nothing.

Any help with this would be very much appreciated.

Thanks in advance,
Julie

HTH + Cheers - Peter

HTH + Cheers - Peter
 
J

Julie

Thanks Peter. I'm still looking for a way out too, and every door seems to
invite more problems.
Julie

Peter Hewett said:
Hi Julie

I don't believe you can identify all characters in a Word document by their
returned unicode values. The problem is that Word masks characters such as
Symbol, Wingdings etc. If you insert a Wingding character in your document and
ask Word what the font is, it returns the name of the font from either the
paragraph style or from directly applied formatting.

Once you've inserted your Winding character select it and then change it's font
- nothing happens to it's appearance, the font name changes but not the
character!

I can't see a way out, I'll have a think and post back if anything occurs to me.

Cheers + good luck - Peter

Thanks Peter

How disappointing. My users are accustomed to having a tool to quickly
strip out unwanted font Names and won't be happy to lose it.

I spent the better part of yesterday writing a macro to make the change
character by character . What a pain! It looked on the surface like it
would be a go but the biggest problem I have is accurately identifying a
non-unicode symbol to avoid disrupting the font for the symbol.

Is there a quick test to identify whether a symbol is a candidate for a font
change or whether the font must be left alone for that symbol?

I read a number of threads about finding symbols and evaluating characters
by character number, but don't see anything on point and what I did read
about characters and how Word crunches the numbers for characters is
difficult for someone at my level to understand. I have a range set to
point to a single character at the time that I need to evaluate the
character and would like to be able to identify whether the character in
that range (1) is a symbol, and (2) if so, is it one that requires the font
name stay).

Thanks,
Julie

Peter Hewett said:
Hi Julie

Nope, you're on target. Once you apply direct formatting you either
live
with
it or remove it! Direct formatting always overrides the style defaults.
Generally you want the directly applied formatting to stick when you update the
style(s). Even character styles don't solve the problem as they're removed if
you do a ".Font.Reset".

As you've discovered resetting the font changes all of the font
attributes
back
to the style default, not just the font name.

Cheers - Peter :(

"Julie" <[email protected]>, said:

Hi Peter.

Thanks for the reply. The method you suggested has been tried and it causes
one of the problems mentioned in my first post, e.g. this code

Sub testit()

Dim opara As Paragraph
Dim oSty As Style

For Each opara In ActiveDocument.Paragraphs
Set oSty = ActiveDocument.Styles(opara.Style)

opara.Range.Font.Name = oSty.Font.Name

Next opara

Set opara = Nothing
Set oSty = Nothing
End Sub


If I run this in Word2000 fully patched running under Windows XP, it does
the job, but .... if LATER I edit the font property of the underlying style,
I am afflicted with the very problem I am trying to resolve. If I try the
code out on some paragraphs styled with Normal, with Normal style currently
set to Arial (but paragraphs manually formtted with TNR), the macro does
what it should - that is apply Arial to all. Later, If I edit Normal style
to change the font to TNR, all of the directly-applied Arial remains - thus,
now my whole document has a direct font applied rather than just part
of
it.
Am I missing something here????

Thanks,
Julie

Hi Julie

Iterate the documents Paragraph collection (use a For Each loop).
Look
up
the
paragraphs style, look up the styles font name and then apply the font
name ass
direct formatting.

HTH + Cheers - Peter


"Julie" <[email protected]>, said:

Hello,

I am writing macros to clean up converted WordPerfect documents and am
stumped trying to figure out how to find and remove directly
applied
font
names without,

- removing any other directly applied font formatting (size, bold,
italic,
etc.), and
- without breaking the ability to later change the font of the underlying
style and have that change take effect for all paragraphs styled with
that
style

(I don't know the name of the font to search for up front - could
be
any
font - always know the name of the font to apply in replacement -
that
is
the default paragraph font name).

Every method I try has its pitfalls (Word2000), including find each style
and replace each style with "no formatting", apply the underling
paragraph
font to the paragraph, etc.

Final result must be that after macro finishes, if user changes the font
of
the underlying style, the change takes effect for all paragraphs with
that
style. All of the methods that I have tried are successful in applying
the
correct font, but they break the ability to make subsequent font changes
to
the underlying paragraph style and have those changes take effect
for
all
relevant paragraphs.

Formerly, in WordPerfect, I was able to achieve this end with a very
simple
macro to find [Font] codes and replace with nothing.

Any help with this would be very much appreciated.

Thanks in advance,
Julie





HTH + Cheers - Peter

HTH + Cheers - Peter
 
K

Klaus Linke

Hi Julie,

Try saving the document after you have run your macro. Word needs this to
"see" that the font now is the same as in the style definition, and doesn't
mean manual formatting any more.

BTW, to find characters from symbol fonts, you can try a wildcard search

With Selection.Find
.Text = "[" & ChrW(&HF020) & "-" & ChrW(&HF0FF) & "]"
.MatchWildcards = True
' ...

This works because Word uses codes between U+F020 and U+F0FF for
"decorative"/Symbol fonts like "Wingdings".
Unfortunately, if you specify the font's name in the search, it will be
ignored.
I think you have to get the font's name from the dialog as described in
http://word.mvps.org/faqs/MacrosVBA/FindReplaceSymbols.htm

Greetings,
Klaus
 
J

Julie

Hi Klaus

I'm glad to see the thread is not dead yet.

I am up to my eyeballs in something urgent today and will try your
suggestions out on the weekend and let you now how it goes.

Sounds good. I have hope. Thank-you.

Julie

Klaus Linke said:
Hi Julie,

Try saving the document after you have run your macro. Word needs this to
"see" that the font now is the same as in the style definition, and doesn't
mean manual formatting any more.

BTW, to find characters from symbol fonts, you can try a wildcard search

With Selection.Find
.Text = "[" & ChrW(&HF020) & "-" & ChrW(&HF0FF) & "]"
.MatchWildcards = True
' ...

This works because Word uses codes between U+F020 and U+F0FF for
"decorative"/Symbol fonts like "Wingdings".
Unfortunately, if you specify the font's name in the search, it will be
ignored.
I think you have to get the font's name from the dialog as described in
http://word.mvps.org/faqs/MacrosVBA/FindReplaceSymbols.htm

Greetings,
Klaus


Julie said:
Hi Peter.

Thanks for the reply. The method you suggested has been tried and it causes
one of the problems mentioned in my first post, e.g. this code

Sub testit()

Dim opara As Paragraph
Dim oSty As Style

For Each opara In ActiveDocument.Paragraphs
Set oSty = ActiveDocument.Styles(opara.Style)

opara.Range.Font.Name = oSty.Font.Name

Next opara

Set opara = Nothing
Set oSty = Nothing
End Sub


If I run this in Word2000 fully patched running under Windows XP, it does
the job, but .... if LATER I edit the font property of the underlying style,
I am afflicted with the very problem I am trying to resolve. If I try the
code out on some paragraphs styled with Normal, with Normal style currently
set to Arial (but paragraphs manually formtted with TNR), the macro does
what it should - that is apply Arial to all. Later, If I edit Normal style
to change the font to TNR, all of the directly-applied Arial remains - thus,
now my whole document has a direct font applied rather than just part of it.

Am I missing something here????

Thanks,
Julie
 
J

Julie

Klaus,

Couldn't wait for weekend to try your suggestions....

Your advice with saving the document solves the problem with the paragraphs
retaining the font. Wonderful! Sometimes the answer is so simple it is
impossible to see.

I still have a show-stopper for cleaning up the font names in the converted
WordPerfect documents, that being the symbols. Before applying the font
name change to a paragraph, I need to detect whether there are WordPerfect
symbols in the paragraph and if so, flag the paragraph for manual follow-up
and not apply the font to paragraphs there found.

I tried out your code, which is much better than what I have, but still have
some problems finding some of the WordPerfect symbols with your code and all
of the other methods I have tried.

The symbols are


1. WP CyrillicB about 40 symbols

2. WP BoxDrawing - 2 symbols

3. WP Box Drawing - about 30 symbols

4. WP MultinationalA Roman - 2 characters

5. and, unfortunately, the WHOLE symbol set for the most frequently used
WordPerfect symbol set - those formatted with the WP Typographical symbols
font.

Those symbols return unexpected numbers. I can detect all of the other
WordPerfect symbols except those ones (with your code, and with other code I
have used). The values returned with ASC() and ASCW() are the same as
regular ASCII text. For example, for the fraction 1/3 symbol from
WPTypographical
symbol font produces these values:

ASC - 97
ASCB = 97
ASCW = 97

Thus, the only way I have found successfully to find these characters is to
search for "any character" formatted with the WordPerfect decorative font.
Is there another way? I don't want to search each and every paragraph for
each and every possible WordPerfect decorative font. I am hoping there is a
better way. Do you know of one?

Thanks again for the VERY HELPFUL advice. Your participation in these
newsgroups has pulled me out of a pickle more than a few times and I
appreciate it.
Thanks.

Julie




Klaus Linke said:
Hi Julie,

Try saving the document after you have run your macro. Word needs this to
"see" that the font now is the same as in the style definition, and doesn't
mean manual formatting any more.

BTW, to find characters from symbol fonts, you can try a wildcard search

With Selection.Find
.Text = "[" & ChrW(&HF020) & "-" & ChrW(&HF0FF) & "]"
.MatchWildcards = True
' ...

This works because Word uses codes between U+F020 and U+F0FF for
"decorative"/Symbol fonts like "Wingdings".
Unfortunately, if you specify the font's name in the search, it will be
ignored.
I think you have to get the font's name from the dialog as described in
http://word.mvps.org/faqs/MacrosVBA/FindReplaceSymbols.htm

Greetings,
Klaus


Julie said:
Hi Peter.

Thanks for the reply. The method you suggested has been tried and it causes
one of the problems mentioned in my first post, e.g. this code

Sub testit()

Dim opara As Paragraph
Dim oSty As Style

For Each opara In ActiveDocument.Paragraphs
Set oSty = ActiveDocument.Styles(opara.Style)

opara.Range.Font.Name = oSty.Font.Name

Next opara

Set opara = Nothing
Set oSty = Nothing
End Sub


If I run this in Word2000 fully patched running under Windows XP, it does
the job, but .... if LATER I edit the font property of the underlying style,
I am afflicted with the very problem I am trying to resolve. If I try the
code out on some paragraphs styled with Normal, with Normal style currently
set to Arial (but paragraphs manually formtted with TNR), the macro does
what it should - that is apply Arial to all. Later, If I edit Normal style
to change the font to TNR, all of the directly-applied Arial remains - thus,
now my whole document has a direct font applied rather than just part of it.

Am I missing something here????

Thanks,
Julie
 
K

Klaus Linke

Hi Julie,

Once you have found and selected some symbol with the wildcard search (I hope that part works?), try to get the font and the code
from the dialog with the code from Dave Rado's article:

With Dialogs(wdDialogInsertSymbol)
Debug.Print "Font: " & .Font
Debug.Print "Char number " & (.CharNum AND &HFFFF&)
End With

Good luck!
Klaus





Julie said:
Klaus,

Couldn't wait for weekend to try your suggestions....

Your advice with saving the document solves the problem with the paragraphs
retaining the font. Wonderful! Sometimes the answer is so simple it is
impossible to see.

I still have a show-stopper for cleaning up the font names in the converted
WordPerfect documents, that being the symbols. Before applying the font
name change to a paragraph, I need to detect whether there are WordPerfect
symbols in the paragraph and if so, flag the paragraph for manual follow-up
and not apply the font to paragraphs there found.

I tried out your code, which is much better than what I have, but still have
some problems finding some of the WordPerfect symbols with your code and all
of the other methods I have tried.

The symbols are


1. WP CyrillicB about 40 symbols

2. WP BoxDrawing - 2 symbols

3. WP Box Drawing - about 30 symbols

4. WP MultinationalA Roman - 2 characters

5. and, unfortunately, the WHOLE symbol set for the most frequently used
WordPerfect symbol set - those formatted with the WP Typographical symbols
font.

Those symbols return unexpected numbers. I can detect all of the other
WordPerfect symbols except those ones (with your code, and with other code I
have used). The values returned with ASC() and ASCW() are the same as
regular ASCII text. For example, for the fraction 1/3 symbol from
WPTypographical
symbol font produces these values:

ASC - 97
ASCB = 97
ASCW = 97

Thus, the only way I have found successfully to find these characters is to
search for "any character" formatted with the WordPerfect decorative font.
Is there another way? I don't want to search each and every paragraph for
each and every possible WordPerfect decorative font. I am hoping there is a
better way. Do you know of one?

Thanks again for the VERY HELPFUL advice. Your participation in these
newsgroups has pulled me out of a pickle more than a few times and I
appreciate it.
Thanks.

Julie




Klaus Linke said:
Hi Julie,

Try saving the document after you have run your macro. Word needs this to
"see" that the font now is the same as in the style definition, and doesn't
mean manual formatting any more.

BTW, to find characters from symbol fonts, you can try a wildcard search

With Selection.Find
.Text = "[" & ChrW(&HF020) & "-" & ChrW(&HF0FF) & "]"
.MatchWildcards = True
' ...

This works because Word uses codes between U+F020 and U+F0FF for
"decorative"/Symbol fonts like "Wingdings".
Unfortunately, if you specify the font's name in the search, it will be
ignored.
I think you have to get the font's name from the dialog as described in
http://word.mvps.org/faqs/MacrosVBA/FindReplaceSymbols.htm

Greetings,
Klaus


Julie said:
Hi Peter.

Thanks for the reply. The method you suggested has been tried and it causes
one of the problems mentioned in my first post, e.g. this code

Sub testit()

Dim opara As Paragraph
Dim oSty As Style

For Each opara In ActiveDocument.Paragraphs
Set oSty = ActiveDocument.Styles(opara.Style)

opara.Range.Font.Name = oSty.Font.Name

Next opara

Set opara = Nothing
Set oSty = Nothing
End Sub


If I run this in Word2000 fully patched running under Windows XP, it does
the job, but .... if LATER I edit the font property of the underlying style,
I am afflicted with the very problem I am trying to resolve. If I try the
code out on some paragraphs styled with Normal, with Normal style currently
set to Arial (but paragraphs manually formtted with TNR), the macro does
what it should - that is apply Arial to all. Later, If I edit Normal style
to change the font to TNR, all of the directly-applied Arial remains - thus,
now my whole document has a direct font applied rather than just part of it.

Am I missing something here????

Thanks,
Julie
 
J

Julie

Thanks Klaus

After pulling my hair out by the roots, I gave up on the symbol find because
of the symbols that return lower ascii values. I cannot find a way to find
them programmatically other than to search for any character in the relevant
font.

If it helps anyone else here....I worked around the problem in my formatting
cleanup project as follows: Early in the process procedure (before any
procedures that alter styles or font formatting run), I call a procedure to
find all of the WordPerfect symbols and convert them to a temporary marker
which holds the symbol number and the font name). That gets the symbols
safely out of the way so that the rest of the conversion procedures can be
free to modify fonts, remove manual font formatting, remove directly-applied
list formatting, etc. Late in the cleanup procedure, close to the end, I
call another procedure to find all of the temporary markers and convert them
back to the original symbols, and highlight the symbols for the user to find
and convert to unicode symbols during the manual post-conversion processes.
A lot of work to that workaound ... but I had to do something because the
symbol find limitations were holding up my project. When time permits, I'll
go back and have another look at it.

Thanks for your help.
Julie


Klaus Linke said:
Hi Julie,

Once you have found and selected some symbol with the wildcard search (I
hope that part works?), try to get the font and the code
from the dialog with the code from Dave Rado's article:

With Dialogs(wdDialogInsertSymbol)
Debug.Print "Font: " & .Font
Debug.Print "Char number " & (.CharNum AND &HFFFF&)
End With

Good luck!
Klaus





Julie said:
Klaus,

Couldn't wait for weekend to try your suggestions....

Your advice with saving the document solves the problem with the paragraphs
retaining the font. Wonderful! Sometimes the answer is so simple it is
impossible to see.

I still have a show-stopper for cleaning up the font names in the converted
WordPerfect documents, that being the symbols. Before applying the font
name change to a paragraph, I need to detect whether there are WordPerfect
symbols in the paragraph and if so, flag the paragraph for manual follow-up
and not apply the font to paragraphs there found.

I tried out your code, which is much better than what I have, but still have
some problems finding some of the WordPerfect symbols with your code and all
of the other methods I have tried.

The symbols are


1. WP CyrillicB about 40 symbols

2. WP BoxDrawing - 2 symbols

3. WP Box Drawing - about 30 symbols

4. WP MultinationalA Roman - 2 characters

5. and, unfortunately, the WHOLE symbol set for the most frequently used
WordPerfect symbol set - those formatted with the WP Typographical symbols
font.

Those symbols return unexpected numbers. I can detect all of the other
WordPerfect symbols except those ones (with your code, and with other code I
have used). The values returned with ASC() and ASCW() are the same as
regular ASCII text. For example, for the fraction 1/3 symbol from
WPTypographical
symbol font produces these values:

ASC - 97
ASCB = 97
ASCW = 97

Thus, the only way I have found successfully to find these characters is to
search for "any character" formatted with the WordPerfect decorative font.
Is there another way? I don't want to search each and every paragraph for
each and every possible WordPerfect decorative font. I am hoping there is a
better way. Do you know of one?

Thanks again for the VERY HELPFUL advice. Your participation in these
newsgroups has pulled me out of a pickle more than a few times and I
appreciate it.
Thanks.

Julie




Klaus Linke said:
Hi Julie,

Try saving the document after you have run your macro. Word needs this to
"see" that the font now is the same as in the style definition, and doesn't
mean manual formatting any more.

BTW, to find characters from symbol fonts, you can try a wildcard search

With Selection.Find
.Text = "[" & ChrW(&HF020) & "-" & ChrW(&HF0FF) & "]"
.MatchWildcards = True
' ...

This works because Word uses codes between U+F020 and U+F0FF for
"decorative"/Symbol fonts like "Wingdings".
Unfortunately, if you specify the font's name in the search, it will be
ignored.
I think you have to get the font's name from the dialog as described in
http://word.mvps.org/faqs/MacrosVBA/FindReplaceSymbols.htm

Greetings,
Klaus


Hi Peter.

Thanks for the reply. The method you suggested has been tried and it
causes
one of the problems mentioned in my first post, e.g. this code

Sub testit()

Dim opara As Paragraph
Dim oSty As Style

For Each opara In ActiveDocument.Paragraphs
Set oSty = ActiveDocument.Styles(opara.Style)

opara.Range.Font.Name = oSty.Font.Name

Next opara

Set opara = Nothing
Set oSty = Nothing
End Sub


If I run this in Word2000 fully patched running under Windows XP, it does
the job, but .... if LATER I edit the font property of the underlying
style,
I am afflicted with the very problem I am trying to resolve. If I
try
the
code out on some paragraphs styled with Normal, with Normal style
currently
set to Arial (but paragraphs manually formtted with TNR), the macro does
what it should - that is apply Arial to all. Later, If I edit Normal
style
to change the font to TNR, all of the directly-applied Arial remains -
thus,
now my whole document has a direct font applied rather than just part of
it.

Am I missing something here????

Thanks,
Julie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top