Results 1 to 7 of 7
  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

    Normal.dot Styles (Word97SR2)

    <pre>Sub test()
    MsgBox ActiveDocument.Styles.Count
    MsgBox ActiveDocument.AttachedTemplate.Styles.Count
    MsgBox NormalTemplate.Styles.Count
    End Sub
    </pre>


    I find it odd that a template cannot have Styles in the sense that documents do.

    The first MsgBox is just fine, but the second generates a run-time error ("438 Object does not support this property or method") on my Word97SR2, and the third generates a compile-time error ("method or data member not found").

    I'd go <font color=red>search</font color=red> for this if I could ... I'm sure it's been asked before. I've probably asked it before ......

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    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: Normal.dot Styles (Word97SR2)

    Is the question: what is the workaround? There must be a workaround, because we've had code posted to compare document styles with template styles. Now that search is back, I hope you will be able to find it (either here or Word).

  4. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Normal.dot Styles (Word97SR2)

    According to the Word (XP) help topic "Styles Collection Object", "The Styles object isn't available from the Template object" and it's suggested that the template is opened as a document (using OpenAsDocument) to access that object. Seems to work for me.

  5. #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: Normal.dot Styles (Word97SR2)

    William, thanks. I can access the Normal.dot styles count by explicity opening it:
    <pre> Dim doc As Document
    Call u.blnOpenFile("C:GreavesAdminTemplatesnormal.dot")
    MsgBox ActiveDocument.Styles.Count
    </pre>


    I'll have to think about this. I'm not sure that I want to deal with "Normal.DOT" as a special case. In particular if I wanted to cross-reference stylers in use in all templates in a set, I'd not want to start checking file names for exceptions.

  6. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Normal.dot Styles (Word97SR2)

    <hr>do others find that their feeling of how it should work does not always coincide with how it does work?<hr>
    Doesn't that apply to life in general, not just VBA?

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

    Re: Normal.dot Styles (Word97SR2)

    > Is the question: what is the workaround?

    (guess what *I* found hiccoughed back in my email, from around the time the lounge resurfaced but I couldn't gain acecss.)

    Ultimately, a workaround in the sense "I must be doing something wrong". My intuition suggested that "Normal.Dot" styles ought to be readily available. My uneducated guess puts 99.997% of all styles in use as being created by non-novice users in their Normal.Dot. Thinking that, Ii figured that Normal.dot styles ought to be readily available to VBA coders.

    I was greatly surprised to find that it ain't so. Usually in these cases I learn that there is a correct way to do something, and I've been doing it wrong. I will go search, now that it is back. You have probably noticed also my other problems with my confusion over "MacroContainer.FullName", for which I must use "ThisDocument" as an object.

    Again, my current experience suggests to me a way of doing something. I find it odd when that lets me down. Is it me, or do others find that their feeling of how it should work does not always coincide with how it does work?

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

    Re: Normal.dot Styles (Word97SR2)

    Life I can (almost) cope with. It's when something supposedly logical lets me down! Again, I suspect that most times my intuition is wrong, based on too-weak an understanding of the VBA/VBE stuff.

Posting Permissions

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