Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Nov 2002
    Location
    London, Gtr London, England
    Posts
    496
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Creating a list template (Word 2K)

    hello woodytes,

    I have been converting my macro recorded macros into something more modular and effective. I have got stuck when creating a list template for the headings. I have created the heading styles, they are Margin aligned for the first 4; headings 5 to nine, which are not designed to be numbered, are first tab aligned. I have the following code which works BUT when getting to the .LinkedStyle line everything doesn't do what I want. What happens is all the heading styles (1-9) change to:
    a) be margin aligned and
    [img]/forums/images/smilies/cool.gif[/img] to be numbered in the pattern Heading 1 = 0., Heading two = 1., Heading 3 = 2 etc; and
    c) there is a tab after the number at .11cm, this measurement doesn't refer to anything I can see.

    Any ideas? many thanks liz

    This is the code for looping round and generating the list template is attached
    Attached Files Attached Files

  2. #2
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a list template (Word 2K)

    Hi Liz,

    Maybe you could start the macro recorder, define the styles as you planned, and then compare the result with your code?

    Problem a)
    See problem c):
    Probably the indent of 1.5 pt is too small to be visible.

    Problem [img]/forums/images/smilies/cool.gif[/img]
    You want to set .ResetOnHigher to True in an outline numbered scheme.
    You used 0 (= False).

    Problem c)
    One problem I see is that measurements in Word are in "points" by default.
    So if you want an indent at 1.5 cm, you'd use CentimetersToPoints(1.5).

    Another possible problem is that
    <pre>With ActiveDocument.Styles(xxStyle)
    .LinkToListTemplate ListTemplate:=xxListTemplate
    End With</pre>

    isn't necessary, as far as I can see -- The styles have already been linked to the list template.
    xxStyle isn't defined, anyway.

    Post back if that doesn't take care of all problems,
    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

  3. #3
    4 Star Lounger
    Join Date
    Nov 2002
    Location
    London, Gtr London, England
    Posts
    496
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Creating a list template (Word 2K)

    Thank you Klaus,

    The 1.5 points was na oversight and explains the .11 cms tab. The reset was another oversight (how is it we can look so hard and not see?) Anyway it's not fixing the fundamental problem. Now what happens immediately after the .LinkedStyle = "Heading " & xxStyleNumber line is:

    Before applying code the headings look like this (the dots represent space, i.e. 1.5 margin/tab and the > represents a tab):

    heading 1
    heading 2
    heading 3
    heading 4
    ......heading 5
    ......heading 6
    ......heading 7
    ......heading 8
    ......heading 9

    First loop results in:
    0.>heading 1
    1.>heading 2
    2.>heading 3
    3.>heading 4
    4.>heading 5
    ......5. heading 6
    ......6. heading 7
    ......7. heading 8
    ......8. heading 9

    Headings 5 - 9 should not be numbered at all. the numbering structure and the reset don't seem to be working I used, .ResetOnHigher = True is this OK? . For Headings 5-9 there is a tab at 0 (which I'd like to get rid of but it doesn't seem possible to say no tab, anyway minor point)

    subsequent loops result in:
    0.>heading 1
    1.>heading 2
    2.>heading 3
    3.>heading 4
    4.>heading 5
    5.>heading 6
    6.>heading 7
    7.>heading 8
    8.>heading 9
    not the numbering increments through the headings even though reset on higher is true and they are all margin aligned with a tab at 1.5cm.

    I can't work it out?

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a list template (Word 2K)

    I'd start with a fresh document. Probably the styles are messed up by the previous macro runs.

    As to the tab at 0: Don't have an idea where this comes from. Maybe from a previous faulty macro?
    To be on the safe side, I usually delete all tabs in the styles before I set up the numbering.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

  5. #5
    4 Star Lounger
    Join Date
    Nov 2002
    Location
    London, Gtr London, England
    Posts
    496
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Creating a list template (Word 2K)

    Klaus,

    What I have discovered (or rather have now observed) is that where I thought it was mucking up the styles definition it is in fact completely correct; the style creation macro creates debug lines in the document using the given style, so i have a line for each heading style, what's happening is that on hitting the code line .LinkedStyle = "Heading " & xxStyleNumber all the text lines using "heading n" are changes to uses "Heading 1" (it does the odd things with alignment as described previously, what I hadn't noticed was that all the lines use "Heading 1"). So my list template creation is OK. But I would like to discover why the text lines using "Heading n" are all converted to use "Heading 1"?

    Incidently I never have historic bugs since to test my macros I am copying them each time into a clean "normal" template as delivered by Microsoft, then running the styles creation macros followed by stepping through the list template creation macro. So in effect it is new each test, tedious but better in the long run.

    thank you for all your help thus far

    liz

  6. #6
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a list template (Word 2K)

    Just guessing (because I haven't time to check your code right now):

    You have deleted the three lines I mentioned in my first reply?
    I know it seems logical to link all styles to the list template, but Word messes it up if you do.
    You might try to just link "Heading 1" to the list template (this is just a guess).

    Your original code contained a variable xxStyle that wasn't defined or set anywhere. I would use "Option Explicit" to avoid such errors.

    In case nobody else comes up with other ideas (or you solve it yourself), I'll have another look at the code in the next days.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

  7. #7
    4 Star Lounger
    Join Date
    Nov 2002
    Location
    London, Gtr London, England
    Posts
    496
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Creating a list template (Word 2K)

    Klaus,

    Solved it!
    Yes had removed the lines as you suggested but couldn't see how everything was linked without it. So at the end of the list template after all done i now do:
    ....With ActiveDocument.Styles("Heading 1")
    .......... .LinkToListTemplate ListTemplate:=xxListTemplate
    ....End With

    As for the text of headings 5 - 9 being margin aligned, although not numbered it takes this from the code line defining .NumberPosition once I had set to be the 1.5 cms this worked perfectly.

    And I do use option explicit as I think it's best practice, it was that you only have a slice of the whole.

    Many thanks for your help

    liz

  8. #8
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a list template (Word 2K)

    > Solved it!

    Glad to hear that. I just looked up some code I got from John McGhie for setting up list styles, and it linked the top level style to the list template, too.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

Posting Permissions

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