Update from Template Troubles

L

Lee

Windows 2K Pro, Word 2K SP-3, I've tried the
http://word.mvps.org/faqs/macrosvba/UpdateStyles.htm
article.

I have created a template with styles defined using VBA,
the styles are linked to outline levels, and the template
lists are named. The styles I am trying to update are
listed in the styles in use screen. When I try to update
styles from the template (tools, templates & add-ins,
automatically update document styles), the style
definitions are, well, redefined for me. . . The links to
the list name and the styles are lost. I can only
reformat the document if I re-run the macros. Not even
the ctrl+a, ctrl+q, ctrl+spacebar works.

I know I'm missing something simple. I just haven't
figured it out yet ;) Any suggestions?

Thanks,
Lee
 
M

Margaret Aldis

Hi Lee

Are you linking the styles from the list template definition, or the other
way around? I've always found that creating the list template and linking
the styles in the list template definition produces a good link that doesn't
break on update styles.

What is it that gets redefined? Remember that tabs and indents will be set
by the list template, not the paragraph settings.
 
L

Lee

Margaret,

I define the styles first, create the list template with
the list levels, and then link the style to the list
template (e.g. heading 1 style is linked to list level 1).

When I update, the links are broken and the heading styles
are redefined. I am not sure where the new settings are
from, but only re-running the macro will fix it. Please
see code below.

Thank you,
Lee

Please note that I am a novice at VBA and have modified
the code commonly posted in the newsgroups.

Here is an excerpt from my macro:

'-------------------------------------------------
'FIRST SET UP THE STYLES
With ActiveDocument.Styles("Heading 1")
.AutomaticallyUpdate = False
.BaseStyle = ""
.NextParagraphStyle = "Body Text Indent"
End With
With ActiveDocument.Styles("Heading 1").Font
.Name = "Arial"
.Size = 14
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Scaling = 100
.Kerning = 0
.Animation = wdAnimationNone
End With
With ActiveDocument.Styles("Heading 1").ParagraphFormat
.LeftIndent = InchesToPoints(0)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 14
.SpaceBeforeAuto = False
.SpaceAfter = 6
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(0)
.OutlineLevel = wdOutlineLevel1
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
'-------------------------------------------------
With ActiveDocument.Styles("Heading 2")
.AutomaticallyUpdate = False
.BaseStyle = "Heading 1"
.NextParagraphStyle = "Body Text Indent 2"
.ParagraphFormat.SpaceAfter = 6
.ParagraphFormat.SpaceBefore = 0
.Font.Size = 11
End With
'-------------------------------------------------
'Continues through to Heading 9
'-------------------------------------------------
'THEN FIND OR CREATE THE LIST TEMPLATE
For Each HeadingsTemplate In ActiveDocument.ListTemplates
If HeadingsTemplate.Name = "HeadingTemplate" Then
TemplateFound = True
Exit For
End If
Next HeadingsTemplate
'--------------------------------------------------
If TemplateFound Then
Set HeadingsTemplate = ActiveDocument.ListTemplates
("HeadingTemplate")
Else
Set HeadingsTemplate =
ActiveDocument.ListTemplates.Add(OutlineNumbered:=True)
HeadingsTemplate.Name = "HeadingTemplate"
End If
'--------------------------------------------------
'--------------------------------------------------
'THEN DEFINE THE LIST TEMPLATE
With HeadingsTemplate.ListLevels(1)
.NumberFormat = "%1."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = InchesToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.4)
.TabPosition = InchesToPoints(0.4)
.ResetOnHigher = True
.StartAt = 1
With .Font
.Bold = True
End With
.LinkedStyle = "Heading 1"
End With
'-------------------------------------------------
With HeadingsTemplate.ListLevels(2)
.NumberFormat = "%1.%2."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = InchesToPoints(0.4)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.85)
.TabPosition = InchesToPoints(0.85)
.ResetOnHigher = True
.StartAt = 1
With .Font
.Bold = True
End With
.LinkedStyle = "Heading 2"
End With
'-------------------------------------------------
 
M

Margaret Aldis

Hi Lee

You've got me - I haven't picked over every line, but I can't see anything
different in your set up from the way I do it, and 'it works here'.

There are some oddities surrounding list template names (whether the name
gets imported or not depends whether it is there already), and if you use
LISTNUM fields or do manual restarts in a document that can get quite
messy - but I've no reason to think that would wreck the update.

Lines of investigation I'd try if it were my document are:

- is it document dependent (can you update other documents or documents
based on other templates)?
- anything odd about the styles and styled paragraphs initially
(automatically updating set on? Direct formatting or list styles applied?)
- how many list templates are in the document before/after the update?
- does resetting the bullets and numbering panes help?
- are there odd list template names in the document (use the LISTNUM field
dialog for a quick list)?
- does setting up the list manually from the top style work better?

Or - if time is less than curiosity is great, you could just write your own
update styles macro and include a reset of the numbering at the end :) (But
I think I'd at least want to rule out document corruption first, since this
is, in my experience, unusual behaviour.)
 

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