Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Nov 2002
    London, Gtr London, England
    Thanked 0 Times in 0 Posts

    Testing for user defined Styles (W2K)

    This is a simple query, I know the answer's in here somewhere but without the serach facility I have to ask the question...

    I want a macro that will search all the styles and if it's user defined delete it, the questions are:
    how do I test of user defined?
    if a delivered style e.g. Normal has been amended can you test for this?
    if a delivered style has been amended will the delete user style clear the user customisation and revert to as delivered?

    in addition can I test for user defined and not used in the current document?
    many thanks liz

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Testing for user defined Styles (W2K)

    The Style object has two properties that you can use, but you must be aware of their idiosyncracies.
    <UL><LI>The BuiltIn property is a Boolean that is True if the style is one of the styles that come with Word, and False if the style has been created by the user.
    <LI>The InUse property is False for built-in styles that have never been used in the present document, and True for built-in styles that have been used at any point during the existence of the document (even if all text with that style has been removed now), and also for all styles created by the user, regardless of whether they have ever been used.
    <LI>To test if a style is really in use, you'd have to loop through all parts of the document and all headers and footers, and search for the style. AFAIK, there is no built-in way to do that.
    <LI>Again AFAIK, there is no way to determine if a style has been modified. You can use the Organizer to copy the style from to the document, but if the style in has been customized, I don't know how to determine this, and if it is possible to revert to the original style definitions without scrapping[/list]I'd wait and see if others have other suggestions.

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Melbourne, Victoria, Australia
    Thanked 295 Times in 267 Posts

    Re: Testing for user defined Styles (W2K)

    As a postscript to Hans assertion that there is no built-in way to determine whether a style is in use.

    This is correct as far as I know but there is an already existing macro in a template that Microsoft supplied with Word 8 called that includes the ability to list the styles currently (actually) in use. That macro uses a search function iteratively to determine whether the style was used. Microsoft dropped this exceptionally useful code from the that came with Word 2000 but it can be made to work there as well.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: Testing for user defined Styles (W2K)

    Regarding "conforming" styles to a standard, I believe there was some code posted that attempted to check a document against a template and fix individual styles in the document. But this is very arduous work making the comparisons, and it might be easier to use the Organizer feature and copy (overwrite) the document styles from the template "en masse."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts