Set "AutomaticallyUpdate" to "false" for all user-defined styles inone go

A

andreas

Dear Experts:

I created a lot of user-defined styles that all start with "Diss_".

I would like to run a macro that sets the property
"AutomaticallyUpdate" to "False" for all user-defined styles that
start with "Diss_".

How am I to achieve this?


Help is much appreciated. Thank you very much in advance.

Regards, Andreas
 
L

Lene Fredborg

The following macro should do what you want:

Sub CustomStyles_DoNotUpdate()
Dim oSty As Style

For Each oSty In ActiveDocument.Styles
If Left(oSty.NameLocal, 5) = "Diss_" Then
oSty.AutomaticallyUpdate = False
End If
Next oSty

MsgBox "Finished."
End Sub

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
A

andreas

The following macro should do what you want:

Sub CustomStyles_DoNotUpdate()
    Dim oSty As Style

    For Each oSty In ActiveDocument.Styles
        If Left(oSty.NameLocal, 5) = "Diss_" Then
            oSty.AutomaticallyUpdate = False
        End If
    Next oSty

    MsgBox "Finished."
End Sub

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word










- Show quoted text -

Hi Lene,

thank you very much for your quick and professional help. I slightly
had to alter the code since it does not work with character styles
beginning with "Diss_". The error code is 5900: This property cannot
be applied to character styles.
_______________
For Each oSty In ActiveDocument.Styles
If Left(oSty.NameLocal, 5) = "Dipl_" And oSty.Type =
wdStyleTypeParagraph Then
oSty.AutomaticallyUpdate = False
End If
Next oSty
__________________________

Thank you very much for your professional help. Regards, Andreas
 
L

Lene Fredborg

You are welcome.

For some reason, I assumed you were talking about paragraph styles only. I
should have included the style type check...

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
A

andreas

You are welcome.

For some reason, I assumed you were talking about paragraph styles only. I
should have included the style type check...

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word








- Show quoted text -

Lene,

never mind. You have helped me so much in the meantime that this
tinty, tiny, tiny oversight is nothing compared to the excellent
coding you have provided so far.
Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top