Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Auto-update of Styles (97 SR-2)

    I would like to use VBA to open a document, set it to NOT auto-update styles, save it, and close it. I know everything I need to do this EXCEPT ... what property to set. Can anyone help? While we're at it, I will also need to know the properties/methods for turning ON auto-spell check and auto-grammar check. Thanks in advance!

    Dale Napier

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Auto-update of Styles (97 SR-2)

    Dale,

    As far as the first question, would something like:

    With Dialogs(wdDialogToolsTemplates)
    .Update = False
    End With

    work?

    Gary

  3. #3
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Correction

    Dale,

    Sorry I think I got the syntax wrong in the previous note. It's a pretty simple one but I can't recall it right now - will post it from work tomorrow.

    As far as setting auto-spell and grammar to on, try the following:

    <pre>With Dialogs(wdDialogToolsOptionsSpellingAndGrammar)
    .AutomaticSpellChecking = True
    .AutomaticGrammarChecking = True
    .Execute
    End With
    </pre>

    Gary

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Auto-update of Styles (97 SR-2)

    To keep your code indented you can place it between the tags
    [PRE ]<pre> and </pre>

    [/PRE]

    Look on the 1-Click Tagpanel just above the box where you enter your post

    StuartR

  5. #5
    Star Lounger
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto-update of Styles (97 SR-2)

    <P ID="edit" class=small>Edited by gwhitfield on 10-Jan-02 12:38.</P>included "pre" tags, as per StuartR's post

    Thanks, everyone, for your ideas. I have to apply this change across multiple levels of directories; I won't bore you with that part of the code. What I had to deal with was making sure that no matter what style someone use, it would not be auto-updated; every style has its own property for this. So what worked was:

    <pre> With ActiveDocument
    ' set auto-add to styles off
    For j = 1 To .Styles.count
    .Styles(j).AutomaticallyUpdate = False
    Next j
    End With </pre>


    I hate the way this removes the indentation from my code!

    Dale Napier

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Auto-update of Styles (97 SR-2)

    <P ID="edit" class=small>Edited by Gary Frieder on 08-May-02 04:09.</P>[Edited May 8, 2002 for context:
    The code below is a refinement of code posted by Dale Napier earlier in this thread.
    The situation that prompts the need for this code is having a document where every style in the document has "Automatically Update" set as a property of the style - in almost every case it's better to leave this setting off.
    Turning it off however would mean manually visiting every style and turning the setting off for each style.
    The macro below enables you to turn the "Automatically Update" off for every style in the document, without having to 'visit' each style.
    You could also use the same macro to turn the Automatically Update setting back on for every style, by changing the 'False' to 'True'.]

    Dale,

    Glad you got a code solution.
    (I was going down a completely different (incorrect) path, thinking you wanted to turn off the "Automatically update document styles" setting in the Templates & Add-Ins dialog.)

    Anyway, a couple of possible improvements on this code:

    (1) You will get a runtime error when the code hits a character style, therefore you need to filter for those.

    (2) Whenever you're working with a collection, it's much faster (up to 100 times faster) to use the For Each construct to loop through the collection (one important exception being when you are deleting members of the collection - then you need to use a counter to loop through the collection backwards).

    <pre>Dim aStyle As Style
    For Each aStyle In ActiveDocument.Styles
    If aStyle.Type <> wdStyleTypeCharacter Then
    aStyle.AutomaticallyUpdate = False
    End If
    Next 'aStyle
    </pre>

    Gary

Posting Permissions

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