Results 1 to 13 of 13
  1. #1
    New Lounger
    Join Date
    Nov 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    List Template List Error in Document (VBA / Word 2002)

    Hello,

    I've written a VBA macro that sets up a list template and then links a style to each of its levels.

    Everything seems fine in documents formatted with this macro. There is no crashing or errors while working in the document or saving it.

    However, I noticed that if I use Word's File, Open and Repair feature on any document in which this macro has
    been run, it informs me that there IS a "List 1" error, that it was able to repair.

    It's idea of "repairing" this error, is to remove the number for level 1 from the outline.

    I'm wondering if anyone else has written any macros to set up outlines, and if so, if they've noticed a similar
    problem.

    And if the document seems fine regardless, should I be concerned about this?

    Like I said, the documents BEHAVE fine, and I would never know the alleged error was there if I didn't experiment
    with Open and Repair.

    I created the code based on books and articles I've read -- I THOUGHT I was doing it properly. (I can post it if that would help)

    Many thanks!
    Laura

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

    Re: List Template List Error in Document (VBA / Word 2002)

    It's probably a good idea to post your code. If it is long, you can attach it in a text file.

  3. #3
    New Lounger
    Join Date
    Nov 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List Template List Error in Document (VBA / Word 2002)

    (Edited by HansV to move long code to attachment - this also preserves indentation.)

    Here goes -- there are a lot of things the macro does, but this is the part that sets up the numbering -- the error shows up in the document even if I don't apply the numbering to any text.

    SORRY I can't seem to get my indents to appear -- I even replaced them with extra spaces but it displays all left aligned on my computer...

    Many thanks to anyone willing to read through this!!!!!!!!!!!
    Laura

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

    Re: List Template List Error in Document (VBA / Word 2002)

    Since your code was rather long, I moved it to an attachment. In general, there are two ways to preserve indentation in a post:

    1. Put <!t>[pre]<!/t> before and <!t>[/pre]<!/t> after the code; this makes the text in between the tags display in a fixed width font "as is".
    2. Use the <!t>[tab]<!/t> tag to indent.

    All these tags can be typed in by hand, or inserted from the 1-Click TagPanel that is available when you compose or edit a post. See <!help=19>Help 19<!/help> for more information.

  5. #5
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: List Template List Error in Document (VBA / Word 2002)

    Hi Laura,

    I've done a bunch of work in the past with List Templates, but before I say anything, I'm a little unclear about what you mean by "Open and Repair." I don't seem to have this feature on my Word 2002. How did you access it?

    Also, I noticed you did not have quotation marks around the style name (StyLev1). Is this a variable, or had you defined this elsewhere in your code? I was able to make your code work by putting quotes around it and creating that style name, but I want to make sure I'm recreating your macro accurately.

    Kim

  6. #6
    New Lounger
    Join Date
    Nov 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List Template List Error in Document (VBA / Word 2002)

    Hi Kim,

    Yes, StyLev1 is a public variable in my template. Although I'd expect putting it in quotes works the same. (?)

    With word 2002, choose File, Open, browse to the doc, and then click the drop down arrow attached to the right side of the open button, you'll see a menu. Open and Repair is at the bottom.

    Again -- I wouldn't have ever known this "error" was existed as the documents seem fine -- except my CLIENT had to go poking around! What concerned me was that if I use Word's built in outline numbering with Heading styles this error is NOT there.

    Thank you for your interest!!!
    Laura

  7. #7
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: List Template List Error in Document (VBA / Word 2002)

    No, if you've assigned it as a variable, you don't need the quotes. I just created a style called StyLev1 and because I was accessing it directly, I had to put it in quotes.

    About Open and Repair -- son of a gun. I will test again and see what I come up with.

    Kim

  8. #8
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: List Template List Error in Document (VBA / Word 2002)

    Here's what happened to me. I created a list template using your code and inserted a numbered paragraph into my document. I saved it, then used Open and Repair to open it. I, too, was told that there was a problem with List1 through List10 and that Word had repaired the document by removing them. The number on my paragraph disappeared, just as you said yours did.

    I closed the document without saving and opened it to edit. I clicked on Format | Bullets and Numbering... and reset any list template that could be reset. The list template controlling the look of my numbered paragraph changed to look like this:
    <pre> Chapter 1Text of the paragraph</pre>


    meaning it reverted to one of the default formatting for that particular list template. I saved the document, then opened with Open and Repair.

    Once again, I got the message that Word detected problems in List1 through List10 and repaired them. However, it *did not* remove the number.

    In KnowledgeBase Article http://support.microsoft.com/default.aspx?...&Product=wd2002, which is about recovering damaged documents, Msoft states "Microsoft Word 2002 attempts to automatically recover a damaged document when it detects a problem with the file." It goes on to say that you can "force" a repair by choosing Open and Repair.

    So here's my theory. There really isn't anything wrong with your document. But because you've "forced" Word to repair the document, it has scanned it to see what's there that's a likely candidate for causing trouble. List templates are one of those things, so it removed it automatically. See, it didn't really detect a problem, it assumed a problem <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

    If anyone out there has a different theory, please pipe up.

    Kim

  9. #9
    New Lounger
    Join Date
    Nov 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List Template List Error in Document (VBA / Word 2002)

    Thanks so much for looking at this. I think what concerns me about the error is that if I use one of Word's Built in List Galleries (one that's linked to heading styles) and modify it (through the styles, not w/ vba code) It does NOT show this error when I open the document.

    You said you've done a lot with list templates. Does my code look "innocent enough" to you?

    I think I'll stop worrying about this (for now) unless something happens to the documents!

    Laura

  10. #10
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: List Template List Error in Document (VBA / Word 2002)

    You're welcome. The code seems fine to me. When I stepped through it I got inconsistent (but I think not dangerous) results on the For Each routine that checks for the existence of the named list template. I have never searched this way for a list template. Since I've always associated a List Template with a specific style -- I check for the style and grab the associated list template (the style has to exist in the document, though). Like this:

    <pre>Set aLstTmplt = ActiveDocument.Styles("StyLev1").ListTemplate
    If aLstTmplt Is Nothing Then
    code to add the List Template...</pre>


    This assigns the list template object variable to the style's list template object. If there is no associated List Template, then the object doesn't exist (Is Nothing).

    I also don't bother to name the List Template, since I can always access it through the style. Word seems to like this a little better (especially in versions earlier than XP). Since I don't know how you use the code, I don't know if this would be appropriate for you, but since it doesn't loop until it finds what it's looking for, it's a little more efficient.

    Kim

  11. #11
    New Lounger
    Join Date
    Nov 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List Template List Error in Document (VBA / Word 2002)

    Ah, interesting.

    I've read all kinds of horror stories about list templates duplicating themselves, and that a style can be inadvertantly linked to a bunch of them (causing inconsistent results when they style is applied, or text is copied), but a list template can only be linked to one style (Maybe I have it backwards!!!!???? Oooooops...). My thought with looping through the code by saying "for each list template in document, if it's the one I want, link it to this style" was that I was avoiding these dangers.

    I'm going to experiment w/ your method and see how it behaves in comparison.

    How these are used, is that I have a numbering toolbar from which the user can pick a pre-defined numbering outline. Then this code runs and sets it up. They use it in the document by applying the styles. They can set up and use multiple outlines in one document, and they can have text that is already formatted with numbering be reformatted with a chosen outline. Stuff like that...

    Thanks!

  12. #12
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: List Template List Error in Document (VBA / Word 2002)

    Oh, I think I know what you're talking about.

    Let's say you want to set up Heading 1 through Heading 9 (it can be any set of styles you want). You edit the "Heading 1" style, click Format, choose Numbering, choose the outline number panel you want to use and click Customize. You format everything the way you want it then click OK, OK and you're back in your document. Then you click Heading 2 and do it all again, until you've edited all Heading styles.

    When you do this, it's possible to inadvertently associate a NEW list template with your Heading style, linking Heading 1 with list template 7, Heading 2 with list template 6, and so on, until they are all criss-crossed and you don't know why numbering doesn't work.

    The List Template dialog can be deceptive -- particularly after you've opened and closed a few documents. You think you're choosing the same List Template, but it can be a copy of the one you chose before. One way to avoid this is to do what you're doing -- using automation. By accessing the list template by name, you ensure that each level is associated with the same list template.

    For anyone reading this wondering how to do this manually: highlight Heading 1 in styles, click modify, click format, choose numbering, choose an outline panel, and choose customize. Format your number, making sure your style is in the "Link level to style:" box. (If you don't see this box, click the More button on the upper right of the dialog.) Then stay in the Customize Outline Numbered List dialog and change levels in the levels box in the upper left of the dialog. Again, you can link the styles in the "Link level to style:" box at the bottom of the screen.

    I hope this is helpful... <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Kim

  13. #13
    New Lounger
    Join Date
    Nov 2003
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List Template List Error in Document (VBA / Word 2002)

    Very helpful, Kim!

    Many thanks!!!

Posting Permissions

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