Results 1 to 10 of 10
  1. #1
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automatically Update Document Styles (Word 97 or 2000)

    I've been playing around with this "feature" & am about to go out on a limb. I'm wondering if anyone else could confirm or dispute what I've found.

    According to Microsoft, WD97: Styles Are Not Automatically Updated When Attaching to a Template and WD2000: Styles Are Not Automatically Updated When Attaching to a Template, documents based on a template other than the normal.dot template will disregard the "Automatically update document styles" option when the normal.dot template is attached. However, this is NOT true; it is true only if you do not USE the identically named style in normal.dot.

    If a document is attached to normal.dot (or any other template), and has "Automatically update document styles" turned on (Tools/Templates & add-ins

  2. #2
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically Update Document Styles (Word 97 or 2000)

    Hi Phil,

    As you said, there really isn't a problem with styles that have been defined in normal.dot (user defined styles or customized built-in styles).
    The only styles for which "Automatically update document styles" doesn't work are the uncustomized (factory default) built-in styles.

    And the reason for that is that they are not stored in Normal.dot at all. They come from some DLL.

    The three methods mentioned in Q211556 are pure BS:

    Method 1 (copy styles from normal.dot with organizer) won't work because the styles aren't in normal.dot.
    Method 2 (apply manual formatting) is so abysmally stupid that I won't comment.
    Method 3 (change the definition of the style by hand) would require that you know all the style settings of the factory default by heart.

    You can copy the factory default styles from some Doc or Dot where they have been used. If you need to do that often, you might start Word with the /a switch (or with a new normal.dot), and create a new template "DefaultStyles.Dot". Then run the following macro once in that template, and save it.
    <pre>Sub UseStyles()
    Dim myStyle As Style
    For Each myStyle In ActiveDocument.Styles
    Selection.Style = myStyle
    Next myStyle
    End Sub</pre>


    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  3. #3
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically Update Document Styles (Word 97 or 2000)

    I just (re)discovered the MVP FAQ article How to safely update a document's styles from its template.

    It seems there really was some problem updating styles from normal.dot in Word97.
    Since I haven't used Word97, I can't say how valid the older article is...
    Perhaps MS just forgot to properly update it for Word2000?

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically Update Document Styles (Word 97 or 2000)

    Hi Klaus:
    Thanks for responding to my observations. I discovered the MVP article shortly after this posting. I have not tested Word 97, but it seems that with both Word 97 & 2000, you can't "Automatically update document styles" until the style is "used" in the template--& the MVP article seems to agree.

    I have used Bill Coan's macro from Cycle a paragraph through all available paragraph styles, eventually returning to the style the paragraph started with. I notice that your macro seems to work faster & is certainly easier to use as it doesn't stop with each style. Is there something that Bill's macro protects against that yours doesn't?

  5. #5
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically Update Document Styles (Word 97 or 2000)

    > Is there something that Bill's macro protects against that yours doesn't?

    His macro cycles the current paragraph through the available paragraph styles. So it has to do more work (determine the current style/next style in the list each time the macro is run, and if it is a paragraph style, and if it's the last style in the list). My macro just applies all styles, and doesn't have to worry about a thing <img src=/S/groovin.gif border=0 alt=groovin width=21 height=21>

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically Update Document Styles (Word 97 or 2000)

    Phil,

    I'm not sure what you're trying to do. But your results seem right, and seem appropriate.

    Styles are copied into a document at the time of its creation from the template. If a style (built-in or otherwise) hasn't been "saved" into the template then it will not be copied into the new document. That is, the "in use" flag has to be true (even in Normal.dot) before a style (with it's modifications) will be copied into a new document.

    I never use normal.dot. Ever.

    I have spent a fair amount of time defining the styles I want for various classes of documents. Once you do this then changing/updating a document from one template to another is very simple and very accurate. If you have BlockBody across a series of letter templates; or heading levels -- then changing templates will change the styles as expected.

    I guess my confusion about your experiment is this: I can see changing the underlying template from Letter1.dot to Letter2.dot and wanting the corresponding styles to update properly. But why would you want to attach Normal.dot (which I think should be considered a repository for modules, not styles) and update styles to Letter1.doc?

    I have a module that will synchronize styles in either direction (from doc to template or from template to document). This copies all user styles no matter what their in-use state. It leaves the built-in styles that are NOT in use alone.

    In my applications (for writing novels and screenplays) I have a command to update styles from the base template (so a user can fix any fiddling they may have done and decided was wrong).

    I rarely, if ever, use the update styles checkbox on Templates and Add-ins.

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically Update Document Styles (Word 97 or 2000)

    Hi Guy:
    Thanks for responding. You said:

    >>I'm not sure what you're trying to do. But your results seem right, and seem appropriate.....
    >>why would you want to attach Normal.dot (which I think should be considered a repository for modules, not styles) and update styles to Letter1.doc?<<

    I'm not actually trying to do anything <img src=/S/noevil.gif border=0 alt=noevil width=25 height=17> & I agree, I don't want to attach normal.dot to update styles. I happened to come across the KB articles & wanted to test their accuracy, as it seemed incorrect. I am wondering about something you said, however. You mentioned that you rarely use the update document styles in Templates & Add-ins to change styles between templates and I was wondering what you do use. Also, could you post the macro that you use to synchronize user styles between documents & templates.

    Thanks again for your input.

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically Update Document Styles (Word 97 or 2000)

    I shouldn't say I never use the Update Styles. In the example I used of having multiple letter templates with slightly varying but identically named styles -- then attaching with update styles checked is correct. But mainly I use the same set of templates and want to be able to make sure any changes in the template are in the document -- and often that changes made only in the document are then copied back to the template.

    I'm actually a little embarrassed to say the macro I use to merge/synchronize styles was written for Word 2.0 (before the update styles checkbox existed) and has never been ported to VBA. It still works, so...

    <pre>
    Public Sub MAIN()
    Dim t$
    Dim d$
    Rem SyncStyles, includes repaint
    If WordBasic.SelInfo(27) Then _
    WordBasic.PrintStatusBar "You are in a macro pane. Cannot get template information.": _
    WordBasic.Beep: _
    GoTo bye
    If WordBasic.FilePrintPreview() Then _
    WordBasic.PrintStatusBar "You are in print preview. Cannot get template information.": _
    WordBasic.Beep: _
    GoTo bye
    If WordBasic.SelInfo(25) Or WordBasic.SelInfo(26) Or WordBasic.SelInfo(28) Then
    If WordBasic.ViewPage() Then
    WordBasic.PrintStatusBar "Moving to body of document..."
    WordBasic.WW7_EditGoTo
    WordBasic.WW7_EditGoTo "PrevSel1"
    Else
    WordBasic.PrintStatusBar "Closing pane..."
    WordBasic.ClosePane
    End If
    End If

    Dim dlg As Object: Set dlg = WordBasic.DialogRecord.FileTemplates(False)
    WordBasic.CurValues.FileTemplates dlg
    t$ = dlg.Template
    If t$ = "" Then WordBasic.Beep: WordBasic.MsgBox "This is a template.": GoTo bye
    d$ = fFileName$(WordBasic.[FileName$](0))
    WordBasic.BeginDialog 528, 146, "Synchronize Styles"
    WordBasic.GroupBox 10, 19, 502, 52, " Direction "
    WordBasic.OptionGroup "Direction"
    WordBasic.OptionButton 20, 31, 293, 16, "Copy document styles &TO template"
    WordBasic.OptionButton 20, 48, 412, 16, _
    "Copy styles &FROM Template into current document"
    WordBasic.Text 20, 81, 499, 13, "The current document is: " + d$
    WordBasic.Text 28, 100, 499, 13, "The current template is: " + t$
    WordBasic.OKButton 314, 117, 88, 21
    WordBasic.CancelButton 420, 117, 88, 21
    WordBasic.EndDialog

    On Error GoTo -1: On Error GoTo bye
    Set dlg = WordBasic.CurValues.UserDialog
    WordBasic.Dialog.UserDialog dlg
    WordBasic.FormatStyle FileName:=t$, Merge:=1, Source:=dlg.Direction
    'If dlg.Direction = 1 Then gLib.RepaintWord
    bye:
    End Sub

    Private Function fFileName$(B$)
    While InStr(B$, "") <> 0
    B$ = WordBasic.[Right$](B$, Len(B$) - InStr(B$, ""))
    Wend
    fFileName$ = B$
    End Function


    </pre>


    Feel free to modify and use as you like. Or drag out of the dark ages and into VBA.


    The operative part is the line:

    WordBasic.FormatStyle FileName:=t$, Merge:=1, Source:=dlg.Direction

    I recall back when I was first fiddling with VBA that this had an advantage over using Organizer Copy and the style collection. But at this point I'm not sure it would be the same to use the CopyStylesFromTemplate Method

    from the help file:

    CopyStylesFromTemplate Method Example


    This example copies the styles from the active document's template to the document.

    ActiveDocument.CopyStylesFromTemplate _
    Template:=ActiveDocument.AttachedTemplate.FullName

    --
    This example copies the styles from the Sales96.dot template to Sales.doc.

    Documents("Sales.doc").CopyStylesFromTemplate _
    Template:="C:MSOfficeTemplatesSales96.dot"

  9. #9
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically Update Document Styles (Word 97 or 2000)

    Thanks, Guy. I'll give it a try. And Klaus, thanks for your macro--much faster & easier to use than what I'd been doing.
    <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>

  10. #10
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically Update Document Styles (Word 97 or 2000)

    As far as I am concerned, the way Word treats the built-in styles is one of the nastier bugs in Word.

    Say you have a lot of different templates, designed for different media (web publishing, articles, memos, email, books ...).
    In principle, the built-in styles are a great idea. You can have the same set of styles for the different publications, and just attach another template to change the appearance.

    Say you've written a newspaper article, and want to publish it on the web. Attach the web publishing template, or copy/paste the text into a document based on that template, and the styles (should) change.

    Unfortunately, it doesn't work that way if the built-in styles haven't been used in the template you are attaching to (or in the document you paste into).

    In both cases, Word should use the factory-preset style definition, but doesn't.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •