Style sheets

L

Larry

What exactly are style sheets? I've seen some references that treat
them simply as tables displaying the properties of the styles in a
document or template. But is there a more dynamic meaning? Is a style
sheet something active that performs some task?

Larry
 
P

Peter Hewett

Hi Larry

Word has styles but does not use style sheets per se for it's documents and
templates. Words styles are functionally equivalent to style sheets. It's
more of a terminology difference. Word styles are stored as part of the
document/template.

The term Style Sheet these days is more used in an HTML or XML/XSL context.
What it refers to is being able to assign block(s) of text a Name and then
assign to that name particular types of formating. This can be font name,
size, bold, italic, etc. Paragraph spacing, indentation, justification etc.
The power of this comes when you want to change the appearance of your
document. Instead of directly applying the changes to the text (which can
take forever in a large document) you change the definition of the styles
assigned to the text. This makes it quick a simple to significantly change
the look of a document or web page.

In HTML you can use either in-line or external style sheets, when Word
generates HTML it uses inline styles.

HTH + Cheers - Peter
 
J

Jezebel

There is no exact meaning.

1) Do a Google on 'Cascading Style Sheets' -- that's what most people use
'style sheet' to mean. These are documents used by web browsers for
rendering web pages. The structure is formally defined as part of the HTML
specification.

2) Some organizations -- especially publishing houses -- use the term to
refer house standards for typography, corporate identity, and (sometimes)
punctuation, list formatting, etc. This is the older meaning.


Within Word, a style sheet is what you get if you print a document selecting
'Styles' from the Print What list: it's a definition of the styles used in
that document. A good style sheet (in the second sense) not only defines the
style but also specifies its use: invaluable for achieving consistency on a
large or team document project.
 
G

GrodanBoll

Are ther any way to seperate the styles from the template?
i'd like to reference in the styles from code or another template. So if I'd like to update the styles, all I have to do is update it in one place.

What is the best way to do this? How do you gurus deal with this problem? :)
 
J

Jezebel

Separating the styles from the template is kind of an oxymoron: templates
are essentially a life-support system for the collection of styles.

There are several ways to update or copy styles in bulk --

1. Use the Organizer: you can copy some or all styles from one document or
template to another.
2. Tools > Templates and Add-ins: you can attach a template to a document
and automatically update all styles as you do so.

Both of these methods can be run from code. You can also (from code) open
the template as a document and iterate its styles, copying them to another
document or template.

It would be easier to suggest a good method if you were more explicit about
your objective.




GrodanBoll said:
Are ther any way to seperate the styles from the template?
i'd like to reference in the styles from code or another template. So if
I'd like to update the styles, all I have to do is update it in one place.
What is the best way to do this? How do you gurus deal with this problem?
:)
 
G

GrodanBoll

Thx for your answer Jezebel

I'm about to code and design a few templates to my company
And I'd like to have all general design and code at one place and reference in it to the templates. So if I update the general design (i.e. the styles) the design in all templates are automaticly updated
I almost know how to this with the code but not with the design

I wish that I could do it the same way a CSS workes

Is it clearer what I'd like to do?
 
J

Jezebel

Your intentions are much clearer. Having been involved with this exercise a
few times, to my jaundiced eye the problems tend to be almost entirely
social and political. In theory it's very simple to introduce company-wide
templates. In practice it falls over when the CEO's PA flatly refuses to use
them, or the Finance Director insists that your template has caused her
department's computers to crash repeatedly. When the assertions have no
logic, it's very difficult to defeat them with reason.

I wish you luck, and hope you don't find yourself sinking rapidly towards
strabismus, insanity and death.


GrodanBoll said:
Thx for your answer Jezebel.

I'm about to code and design a few templates to my company.
And I'd like to have all general design and code at one place and
reference in it to the templates. So if I update the general design (i.e.
the styles) the design in all templates are automaticly updated.
 
G

GrodanBoll

Hehe, thx I'll try not to. :

----- Jezebel wrote: ----

Your intentions are much clearer. Having been involved with this exercise
few times, to my jaundiced eye the problems tend to be almost entirel
social and political. In theory it's very simple to introduce company-wid
templates. In practice it falls over when the CEO's PA flatly refuses to us
them, or the Finance Director insists that your template has caused he
department's computers to crash repeatedly. When the assertions have n
logic, it's very difficult to defeat them with reason

I wish you luck, and hope you don't find yourself sinking rapidly toward
strabismus, insanity and death


GrodanBoll said:
Thx for your answer Jezebel
And I'd like to have all general design and code at one place an
reference in it to the templates. So if I update the general design (i.e
the styles) the design in all templates are automaticly updated
 
C

Charles Kenyon

Larry,

What I've done in my letterhead is code that checks to see if the attached
template is the original "base" template. If it is not, it updates the
contents of the attached template copying styles as well as header/footers
from the base template to the new document. The base template has a document
variable with the name of that template. Other templates are created from
the base using SaveAs so they have the same document variable with the name
of the original template. So will documents created based on the derivative
templates. This allows for multiple base template sets.

The first part of it follows.

Dim sTemplateName As String
sTemplateName = ActiveDocument.Variables("BaseName").Value
' If this is not the base template for the letterhead, attach base
template
If ActiveDocument.AttachedTemplate.Name <> sTemplateName Then
ReplaceHeaders (sTemplateName) ' calls private sub (below)
' Application.OrganizerCopy( ' (for future work to update letterhead
styles)
AttachBase (sTemplateName)
End If

It is not necessary to attach the base to the new document, I just found
that to be a convenient way to update the styles. I don't do it in templates
that have customizations of their own beyond the text they contain.

Additional code follows:
Function WorkGroupPath() As String
' Written by Charles Kenyon
' February 28, 2003
'
' Used by templates menus to set location of templates.
' Returns workgroup tempates path with "\" at the end.
'
' This is needed because if the folder is a network drive rather
' than a folder, it will have the "\" already. If it is a folder,
' it will not have the backslash. This function gives a string
' with the backslash in either case.
'
WorkGroupPath =
Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath)
If Right(WorkGroupPath, 1) <> "\" Then
WorkGroupPath = WorkGroupPath & "\"
End If
End Function

Private Sub AttachBase(sTemplateName As String)
' Procedure written by Charles Kyle Kenyon 8 Dec 2003
' Reattaches Base Letterhead Template for form letters - attaches styles
'
Dim sTemplatesPath As String
sTemplatesPath = WorkGroupPath & "Letters & Faxes\"
'
With ActiveDocument
.UpdateStylesOnOpen = True
.AttachedTemplate = sTemplatesPath & sTemplateName
.UpdateStylesOnOpen = False
.AttachedTemplate = sTemplatesPath & sTemplateName
End With
End Sub

Private Sub ReplaceHeaders(sTemplateName As String)
' Replaces Header and FirstPageHeader with contents from
' base template
' Replaces Footer and FirstPageFooter with contents from
' base template
' Assumes that bookmarks have been preserved in base and copies.
' Otherwise will generate error
' Required bookmarks are "Footer1," "Footer2," "Header1," and
"Header2"
'
Dim rRange As Range
Dim sFooter As String
Dim sHeader As String
Dim iCount As Integer
'
' For iCount = 1 To 1 ' Replace 1st page header/footer only
For iCount = 1 To 2 ' Replace both headers, letterhead & continuation
sFooter = "Footer" & iCount
sHeader = "Header" & iCount
Set rRange = ActiveDocument.Bookmarks(sHeader).Range
rRange.InsertFile FileName:=WorkGroupPath _
& "Letters & Faxes\" & sTemplateName, _
Range:=sHeader, _
ConfirmConversions:=False, Attachment:=False, Link:=False
Set rRange = ActiveDocument.Bookmarks(sFooter).Range
rRange.InsertFile FileName:=WorkGroupPath _
& "Letters & Faxes\" & sTemplateName, _
Range:=sFooter, _
ConfirmConversions:=False, Attachment:=False, Link:=False
Next iCount
End Sub

This way I generally only have to make changes to either the document's
styles or adding macros / toolbars or keyboard customizations to the base
template. If you use the organizerCopy method, be sure you copy styles three
times (Copy all desired styles once, then again, then again) to make sure
that links between styles are maintained. Hope this gives you a start.
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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