View Single Post
 
Old 01-16-2023, 03:54 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,980
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

When you copy from one file to another there are two ways that the styles might be updated in the target file.
1. Custom (non built-in) styles get added to the target
2. Style aliases in source might get added to the built-in style names in the target

To deal with both these, since we are intentionally removing the style info from the source, there is no problem with blowing away the custom styles in the target before we copy. Similarly, you can remove all style aliases before that copy. The following macro could be applied to the source before copying.
Code:
Sub NukeStyles()
  Dim aSty As Style, i As Integer
  On Error Resume Next
  'Get rid of custom styles
  For i = ActiveDocument.Styles.Count To 1 Step -1
    Set aSty = ActiveDocument.Styles(i)
    If Not aSty.BuiltIn Then aSty.Delete
  Next i
  'remove any style aliases
  For Each aSty In ActiveDocument.Styles
    aSty.NameLocal = Split(aSty.NameLocal, ",")(0)
  Next aSty
End Sub
I'm not sure on the issue you are having with Body Text. The UpdateStyles line in the code I gave you previously 'should' be re-importing all the style settings from the source template so Body Text would be refreshed as part of that command.

You can't delete 'Body Text' since it is a built-in style. Word's GUI pretends that you can delete it but really it just hides the style.

What attributes of the Body Text style are being imported from the source file that weren't already in the template's body text style?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote