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

From: Julie (abc_at_abc.com)
Date: 04/09/04


Date: Fri, 9 Apr 2004 10:56:10 -0700

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
> >
> >
>



Relevant Pages

  • Re: How do I paste text into Word in the documents font face?
    ... No, you'd have to run the macro manually, for example, by adding it to ... Sub EditPaste() ... >> Stefan Blom ... >>> feature of retaining the original font and text characteristics. ...
    (microsoft.public.word.docmanagement)
  • Re: EXCEL VALUE PASTING
    ... "CANNOT EDIT A MACRO ON A HIDDEN WORKBOOK.UNHIDE THE WORKBOOK USING THE ... Sub LowerCase() ... way to list all existing shortcut keys. ... changing case and font size. ...
    (microsoft.public.excel.programming)
  • Re: What happened to context-sensitive Help in Word 2007?
    ... command in the old UI and it will show you where the command is found in the ... works in the Font dialog box. ... and "Indent paragraphs." ... Guess it's a new feature and the Help's not finished, ...
    (microsoft.public.word.docmanagement)
  • RE: EXCEL VALUE PASTING
    ... "CANNOT EDIT A MACRO ON A HIDDEN WORKBOOK.UNHIDE THE WORKBOOK USING THE ... changing case and font size. ... name in the list, press the button, and assign a shortcut key. ... Sub Lowercase() ...
    (microsoft.public.excel.programming)
  • font type conditional formatting based on if
    ... if you want to use a macro you have to use the ... I need the font of the character and the cell ... well as the characters are typed or the results of a ... Target.Cells.Count> 1 Then Exit Sub ...
    (microsoft.public.excel.worksheet.functions)