Re: Macro to Remove Direct Font Name without Removing other font properties
From: Peter Hewett (nospam_at_xtra.co.nz)
Date: 04/10/04
- Next message: Doug Robbins - Word MVP: "Re: Code to delete footnotes"
- Previous message: Peter Hewett: "Re: Restrict input to an input box to numerical format"
- In reply to: Julie: "Re: Macro to Remove Direct Font Name without Removing other font properties"
- Next in thread: Julie: "Re: Macro to Remove Direct Font Name without Removing other font properties"
- Reply: Julie: "Re: Macro to Remove Direct Font Name without Removing other font properties"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Doug Robbins - Word MVP: "Re: Code to delete footnotes"
- Previous message: Peter Hewett: "Re: Restrict input to an input box to numerical format"
- In reply to: Julie: "Re: Macro to Remove Direct Font Name without Removing other font properties"
- Next in thread: Julie: "Re: Macro to Remove Direct Font Name without Removing other font properties"
- Reply: Julie: "Re: Macro to Remove Direct Font Name without Removing other font properties"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|