Global StyleSheet?

ADD Balance - trademark of Charles Kenyon, Attorney at Law and Webmaster.
Microsoft Word - Frequently Asked Questions - click to go to the question list.

on ADD Balance by Madison Wisconsin Criminal Defense Lawyer Charles Kenyon

Thank you for the suggestions. ("Smilies" from Woody's Lounge.) Click to go to Lounge. with input and suggestions from many on Thank you for the suggestions. ("Smilies" from Woody's Lounge.) Click to go to Lounge.
the Microsoft Newsgroups and at Woody's Lounge 

Click here to skip past FAQ questions list and other info and go directly to the start of this topic.

Remember to Refresh your page. [F5] in Internet Explorer. [Ctrl-R] in Netscape.

Home
Word Tutorial - Intermediate
Legal Users Guide to Word
Downloads
Books about Microsoft Word - Newsgroup suggestions
Links
Web Resources for Microsoft Word

Using Date Fields in Microsoft Word
Calculated Dates
Booklet Formatting and Printing in Microsoft Word
Changing the Default Font in Microsoft Word
Document linked to Printer in Microsoft Word
Fonts Missing from Menu in Microsoft Word
How can I get a different header / footer on the second page?
More on Headers and Footers in Word
Letterhead
Weird Lines and Borders
Macros and VBA
Master Documents Feature in Microsoft Word
Moving (Sharing) Customizations in Microsoft Word
Global StyleSheet?
MVP means?
Naming Files - A System is the Key
Netiquette - Posting tips in the Microsoft Word news groups
Getting rid of that (*)#"@^ paperclip! - Taming the Office Assistant
Page X of Y doesn't work in Microsoft Word!
Save Changes to the Global Template? Keeps Popping Up
Templates in Microsoft Word
Global Templates
Too Many Icons on the Taskbar in Microsoft Word 2000
Getting Rid of the Web Toolbar in Microsoft Word
Word for Word Perfect Users
Favorite Documents Menu
Work Menu in Microsoft Word
Templates Menu in Microsoft Word
What books have been recommended about Microsoft Word?
Where can I find more templates?
Word Links

(Completely off-topic but I like history)

 

 

A Global StyleSheet in Microsoft Word

Global Templates work very well for sharing most kinds of customizations in Word. The big exception is styles. Styles contained in global templates are ignored by documents.

A macro, though, can be used to copy styles from a global template to the active document. What follows is such a macro to copy the style Body Text and Heading Styles 1-9 from a global template to the active document. If there is no document open, it will generate a message box.

Before copying the styles, the macro asks whether the person is sure that he/she wants to redefine the styles. If "yes", then it will copy the styles using the Organizer. If no, it exits.

Sub StyleCopyMacro()
'
' StyleCopy Macro written by Charles Kyle Kenyon 14 November 2001
' Copyright 2001 All rights reserved
' Copies styles from stylesheet global template to active document
'
' Declare variables
    Dim sThisTemplate As String
    Dim sTargetDoc As String
    Dim i As Integer ' Counter 1 - use for copying styles three times
    Dim iCount As Integer ' Counter 2 - use to loop copying of heading styles
    Dim rResponse As Variant ' can be vbMsgBoxResult in Word 2000 or later
' Error Handler set
    On Error GoTo NoDocument ' Call when no document is open.
' Define This Template and Target Document variables
    sThisTemplate = ThisDocument.FullName ' name and path of global template
    sTargetDoc = ActiveDocument.FullName 'generates error if no document open
' If any other errors, continue on
    On Error Resume Next
    rResponse = MsgBox(Prompt:="This command redefines your Body Text Style and" _
        & vbCrLf & "Heading Styles 1-9. Are you sure you want to do this?" _
        & vbCrLf & vbCrLf & "If you are not sure, answer 'No' and make a backup of your document." _
        & vbCrLf & "Then run the command to copy the styles again.", _
        Title:="Are you sure you want to redefine your styles?", _
        Buttons:=vbYesNo + vbExclamation)
    If rResponse = vbNo Then Exit Sub
    ' Copy Body Text and Heading Styles to Active Document
    ' Note that this requires exact style names
    For i = 1 To 3 ' copy styles three times to maintain linkages
        With Application
            .OrganizerCopy Source:=sThisTemplate, _
                Destination:=sTargetDoc, Name:="Body Text", Object:= _
                wdOrganizerObjectStyles
            For iCount = 1 To 9 'Copy heading styles 1-9
                .OrganizerCopy Source:=sThisTemplate, _
                    Destination:=sTargetDoc, Name:= _
                    "Heading " & iCount, _
                    Object:=wdOrganizerObjectStyles
            Next iCount
        End With
    Next i
    Exit Sub ' Skip error handler routine
NoDocument: ' Error Handler - Will be called if there is not an open document
MsgBox Prompt:="Sorry, this command is only available when you have a document open.", _
    Title:="No document open!", Buttons:=vbExclamation
End Sub

End of procedure (macro). (I didn't say it would be easy, just that it could be done!)

For instructions on copying this macro into your template, see Macros and VBA.

Additional Thoughts

An alternative would be to have a separate stylesheet residing in a predetermined place on the system, possibly in a folder in the Workgroup templates folder. Then use the Organizer to copy styles from that stylesheet. This would have the advantage of being able to have multiple style sets available using the same style names.

It is expected that the macro would be attached to a menu command in the global template under the Format menu. It could also be called as part of the AutoNew macro in particular document templates to pull in or refresh styles in those document templates. With this particular macro, the heading styles are intended to be used for numbering and the template attaches the Heading 1 style to the numbering button on the Formatting menu and removes the Bullets and Numbering dialog from the Format menu.

It is important that you understand how styles interact with one another and with Word's other features. The macro given here copies the Body Text style as a base style. In the template it is taken from the other styles all base their font on Body Text. If the styles being copied are based on a built-in or existing style which is not copied, you may end up with unexpected results. You can also end up with desired results; sometimes you want the formatting in the document to be very different from the formatting in the global template, if that makes it fit into the document better. It is up to you, as the crafter of the template, to make sure that if your user is surprised by the results, it will be a pleasant surprise.

If you want the copied styles to not be effected by any style definitions already in the document and to not effect text already in the document, you would want your copied styles to (1) not be based on any built-in style (including "normal") and (2) to not have the same name as any style already being used in the document.

See Understanding Styles in Microsoft Word for more on styles. You may also want to take a look at the StyleRef Field Tutorial, the IncludeText Field Tutorial, and the Letterhead Textboxes and Styles Tutorial for a better idea of how styles can interact with each other.

Copyright 2000-2006 Charles Kyle Kenyon

FAQ provided as an adjunct / hobby as a part of my web site as a criminal defense lawyer.

 

Smile! Bumper stickers and jokes.

Using Date Fields in Microsoft Word
Calculated Dates
Booklet Formatting and Printing in Microsoft Word
Changing the Default Font in Microsoft Word
Document linked to Printer in Microsoft Word
Fonts Missing from Menu in Microsoft Word
How can I get a different header / footer on the second page?
More on Headers and Footers in Word
Letterhead
Weird Lines and Borders
Macros and VBA
Master Documents Feature in Microsoft Word
Moving (Sharing) Customizations in Microsoft Word
Global StyleSheet?
MVP means?
Naming Files - A System is the Key
Netiquette - Posting tips in the Microsoft Word news groups
Getting rid of that (*)#"@^ paperclip! - Taming the Office Assistant
Page X of Y doesn't work in Microsoft Word!
Save Changes to the Global Template? Keeps Popping Up
Templates in Microsoft Word
Global Templates
Too Many Icons on the Taskbar in Microsoft Word 2000
Getting Rid of the Web Toolbar in Microsoft Word
Word for Word Perfect Users
Favorite Documents Menu
Work Menu in Microsoft Word
Templates Menu in Microsoft Word
What books have been recommended about Microsoft Word?
Where can I find more templates?
Word Links

Click to return to table of contents page of Intermediate User's Guide to Microsoft Word.Click to go to Microsoft Word new users frequently asked questions site in a new browser window.
(Intermediate Users' Guide) - - - - - - - - - - - - - - - - - - -  (Questions List)

Home
Word Tutorial - Intermediate
Legal Users Guide to Word
Downloads
Books about Microsoft Word - Newsgroup suggestions
Links
Web Resources for Microsoft Word