Re: Macro to Remove Direct Font Name without Removing other font properties

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Peter Hewett (nospam_at_xtra.co.nz)
Date: 04/10/04


Date: Sat, 10 Apr 2004 12:24:47 +1200

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" <abc@abc.com>, 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
>
>"Peter Hewett" <nospam@xtra.co.nz> wrote in message
>news:qbcd705740fr8nnia9mt2jmb0lg5nkedh2@4ax.com...
>> 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" <abc@abc.com>, 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
 



Relevant Pages

  • Re: Macro to Remove Direct Font Name without Removing other font properties
    ... character by character. ... non-unicode symbol to avoid disrupting the font for the symbol. ... Direct formatting always overrides the style defaults. ... >> For Each opara In ActiveDocument.Paragraphs ...
    (microsoft.public.word.vba.general)
  • Re: Entering text in Word 2004 only possible in Times New Roman for certain keyboard layouts??
    ... them immune from direct formatting overlayed upon them. ... Body Text style back to your preferred font. ... Make sure that when you change away from TNR you go to one of the fonts Paul ... toolbar button and/or a keyboard shortcut to apply Arial font. ...
    (microsoft.public.mac.office.word)
  • assure that style defs are uniform?
    ... You can strip all direct formatting from a paragraph (or ... many selected paragraphs at once) by pressing Ctrl+Q to ... macro. ... >individual paragraphs that use that Style. ...
    (microsoft.public.word.formatting.longdocs)
  • Re: Entering text in Word 2004 only possible in Times New Roman for certain keyboard layouts??
    ... them immune from direct formatting overlayed upon them. ... Body Text style back to your preferred font. ... Make sure that when you change away from TNR you go to one of the fonts Paul ... toolbar button and/or a keyboard shortcut to apply Arial font. ...
    (microsoft.public.mac.office.word)
  • Re: Finding and Changing font
    ... "Terry Farrell" wrote in message ... However, if it is a document that is going to be around for some time - perhaps used as a template for other documents - it should be formatted correctly, which may mean removing all the direct formatting and then applying styles throughout. ... the cursor in the FIND box, click on Format and select Font and chose the font parameters you want to replace. ... Then go to the replace box and do the same but selecting the font parameters you want to use. ...
    (microsoft.public.word.newusers)