Quote:
Originally Posted by slaycock
There is a check box on the file.option.add-ins.templates dialog box that automatically imports the attached template styles.
|
That won't add any new Styles to the documents and effectively prevents users redefining any existing Styles unless they're applied to the template also.
John9210: All you need is a macro like:
Code:
Sub UpdateDocumentStyles()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document
strDocNm = ActiveDocument.FullName
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
If strFolder & "\" & strFile <> strDocNm Then
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
With wdDoc
'Copies all styles from the attached template into the document,
'overwriting any existing styles in the document that have the same name.
.UpdateStyles
'Resets all existing styles in the document to match the styles in the
'attached template each time the document is opened.
'.UpdateStylesOnOpen = True
.Close SaveChanges:=True
End With
End If
strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
Note the commented-out '.UpdateStylesOnOpen = True' line. If you in-comment that line, the action noted in the preceding comment will take effect, effectively preventing users redefining any existing Styles unless they're applied to the template also.