Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Storing Custom Styles (XP)

    Our users want to create their own custom styles for use across many documents attached to many different templates. The custom templates are locked off to them for obvious maintenance reasons. When I allow them to store their custom styles in normal.dot OR into a custom global template in the startup directory, they are unable to access those styles from a document attached to a custom template. I know this can be done and I'm banging my head with this Styles Task Pane trying to figure out what is going on.

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

    Re: Storing Custom Styles (XP)

    Styles are stored in the template upon which a document is based.

    At the time of document creation, the styles in the based upon template are copied into the document.

    Subsequent changes to the styles can be saved into the document only or (with a checkbox) saved to the template as well.

    Interesting challenge.

    Styles stored in the normal dot are ONLY available to Normal.dot templates. Styles based in Global-Add-ins are not copied to any document.

    You could create a macro for each station that would copy the current style (with any Mods) into the Normal.dot you would have to have a module that copied the current style (from the template document) into Normal... and then when a new document was created, a module to copy the modified style from Normal back to the current document.... easy enough to do one style at a time, more difficult to write so that it would merge all styles at one go.

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

    Re: Storing Custom Styles (XP)

    Here are three macros. The first two operate on the current selection, and work with the current selections style. They will copy both built-in and user styles. You could create two buttons and assign them: Copy To an CopyFrom.

    The third copies all user defined styles from the current document into Normal.dot. Should give you an idea for a possible solution:

    <pre>Sub CopyCurrentStyleToNormal()
    '6/29/02 by Guy Gallo
    '
    Dim ThisDoc
    Dim nTemplate
    ThisDoc = ActiveDocument.FullName
    nTemplate = NormalTemplate.FullName

    Application.OrganizerCopy Source:=ThisDoc, _
    Destination:=nTemplate, _
    Name:=Selection.Style, _
    Object:=wdOrganizerObjectStyles

    End Sub

    Sub CopyCurrentStyleFromNormal()
    '6/29/02 by Guy Gallo
    '
    Dim ThisDoc
    Dim nTemplate
    ThisDoc = ActiveDocument.FullName
    nTemplate = NormalTemplate.FullName

    Application.OrganizerCopy Source:=nTemplate, _
    Destination:=ThisDoc, _
    Name:=Selection.Style, _
    Object:=wdOrganizerObjectStyles

    End Sub
    Sub CopyAllUserStylesFromNormal()
    Dim ThisDoc
    Dim nTemplate
    ThisDoc = ActiveDocument.FullName
    nTemplate = NormalTemplate.FullName
    Dim objStyle As Style
    For Each objStyle In ActiveDocument.Styles
    If objStyle.BuiltIn = False Then
    On Error Resume Next
    Application.OrganizerCopy Source:=nTemplate, _
    Destination:=ThisDoc, _
    Name:=Selection.Style, _
    Object:=wdOrganizerObjectStyles
    End If
    Next objStyle

    End Sub

    </pre>


  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Storing Custom Styles (XP)

    Here's another possible way to do it:

    Have the users create a "style sheet" which is a run of paragraphs where each paragraph has one of their custom styles applied. (For convenience, the text of each paragraph can consist of the name of the style that's applied to that paragraph.)

    Have them select this range of paragraphs and save it to their Normal.dot as an autotext.

    Then if they ever want to insert their custom style set into a document, they can just insert the style sheet autotext, and immediately select and delete it. All of the styles that were in the inserted style sheet autotext, should remain associated with the document.

    Once the autotext is created, the steps of inserting the autotext, selecting and deleting it can easily be done via a macro.

    Gary

  5. #5
    New Lounger
    Join Date
    Jun 2002
    Location
    PA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Storing Custom Styles (XP)

    From my experience, merging or copying styles is less reliable than a macro that just creates the style:
    For example, see this example of a macro I use to create a character style. This could be
    easily modified to create a group of paragraph or character styles. Hope this helps.

    Sub CreateMyStyle()
    Dim isty, nosty, x: For isty = 1 To ActiveDocument.Styles.Count
    If ActiveDocument.Styles(isty).NameLocal = "mystyle" Then
    x = MsgBox("The style mystyle already exists.", vbOKOnly, "mystyle Style")
    End
    End If
    Next isty
    ActiveDocument.Styles.Add Name:="mystyle", Type:=wdStyleTypeCharacter
    ActiveDocument.Styles("mystyle").BaseStyle = "Default Paragraph Font"
    x = MsgBox("Created the style mystyle.", vbOKOnly, "mystyle Style")
    End Sub

Posting Permissions

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