Macro to import styles

Word 2007. I have a lot of older Word documents that I want to update with my current set styles. Is there a macro that will import the styles from my Normal dot file? I've tried creating one with the Run command, but it doesn't work. It results in an error. It wants to import the styles into the document I had open when I created the macro!

If you attach your new normal template to the documents, with the updatestyles on open option set, it should achieve what you require.

The following should do the job

    With ActiveDocument
        .UpdateStylesOnOpen = True
        .AttachedTemplate = "Normal"
        .UpdateStylesOnOpen = False
    End With

http://www.gmayor.com/installing_macro.htm   

If this achieves what you require, with a little modification you can use this as a custom process with http://www.gmayor.com/document_batch_processes.htm i.e.

Function ApplyTemplate(oDoc As Document) As Boolean
    On Error GoTo Err_Handler
    With oDoc
        .UpdateStylesOnOpen = True
        .AttachedTemplate = "Normal"
        .UpdateStylesOnOpen = False
    End With
    ApplyTemplate = True
lbl_Exit:
    Exit Function
Err_Handler:
    ApplyTemplate = False
    Resume lbl_Exit
End Function

Graham Mayor (Microsoft Word MVP 2002-2019)
For more Word tips and downloads visit my web site
https://www.gmayor.com/Word_pages.htm

2 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

It did not work  for me. I created the macro as follows:

With ActiveDocument
  UpdateStylesOnOpen = True
  AttachedTemplate = "Normal"
  UpdateStylesOnOpen = False
End With

But when I run it, it does not import the styles. Am I missing somenting. I installed the macro in a document. Should I install it in normal.dot?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 401 Applies to: