Results 1 to 5 of 5
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Obtaining styles from AttachedTemplate (Word97SR2)

    I feel like I'm going bonkers. It's that time of year when I mess around with styles. I've searched the lounge in various ways and can't resolve this little problem:

    How do I determine if a Style exists in a document's AttachedTemplate?

    I can do wondrous things with ActiveDocument.Styles

    I can do three things with Organiser (Copy, Rename and Delete); I don't want to resort to OnError unless I have to.

    The Template object doesn't appear to allow me to look at its .Styles.

    I want this function (below), but operating on the document's AttachedTemplate. Or any Template for that matter. What am I missing? Has my brain finally turned to fluff?

    <pre>Public Function sty(doc As Document, strStyleName As String)
    Set sty = Nothing
    Dim lng As Long
    For lng = 1 To doc.Styles.Count
    If doc.Styles(lng).NameLocal = strStyleName Then
    Set sty = doc.Styles(lng)
    Exit Function
    Else
    End If
    Next lng
    'Sub TESTsty()
    ' Dim sty1 As Style
    ' Set sty1 = sty(ActiveDocument, "Text 1")
    ' If sty1 Is Nothing Then
    ' MsgBox "Does Not Exist"
    ' Else
    ' MsgBox "exists!"
    ' End If
    'End Sub
    End Function

    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Obtaining styles from AttachedTemplate (Word97SR2)

    As you have found, Styles is not a property of the Template object, only of the Document object. You will have to open the attached templete as a document (using Documents.Open) to get at its Styles collection.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Obtaining styles from AttachedTemplate (Word97SR2)

    > It's that time of year when I mess around with styles.

    Actually, you usually seem to do this in December:

    2003: http://www.wopr.com/cgi-bin/w3t/showflat.p...b&Number=326028
    2002: http://www.wopr.com/cgi-bin/w3t/showflat.p...b&Number=207245

    <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Obtaining styles from AttachedTemplate (Word97

    > open the attached template

    Thanks Hans, this is what I'll do.

    Not a big deal in this case, because I'm verifying styles in a large set of documents against a single, common, standard, attached template. I can open the template, load existing styles into an array, and close the template. Then I can match the array against each document.

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Obtaining styles from AttachedTemplate (Word97

    > Actually, you usually seem to do this in December:

    Aaaaaaargh. I'm losing "it". How come you could find my posts when I couldn't (search and) find them?
    Thanks. As Hans has pointed out, it's a problem, and as you have pointed out, I once knew it was a problem. Now I have another problem (grin!)

Posting Permissions

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