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

    Create Styles Macro & ContinuePreviousList (2003)

    Dear Loungers,

    I have macros that I use to create new, clean templates. Part of the macro creates list styles, the simple bulleted lists and numeric and alpha lists. All I need to do is e.g.
    1. first list item
    2. second list item
    some other text in between
    1. new list first item
    2. new list second item

    so I want the numbering to restart. this used to work fine pre-xp, but now my list styles always continue from the last one. So in the example above the numbering would be 1,2,3,4.

    how can I best do this within a macro whilst creating the style?

    liz

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Create Styles Macro & ContinuePreviousList (20

    I have seen people do this in the past but I am yet to be convinced that you need to create all the styles through code - the primary purpose of a template is for creating new documents with all the styles already created in it.

    But since you asked - Lists associated with styles have behaved this way since Word 97. The only possible way to do this exclusively with styles is to assign the list elements as an outline list and set the 1st level as an unnumbered style (eg Normal) and set the numbering to start at level 2. Then if the styles are used each level 2 style restarts after a Normal paragraph. I wouldn't recommend doing it this way as you will be restricted to only one numbering pattern to use Normal as the resetting style and if you used another style in between the separate list then the numbering will continue by default.

    The other solution (which I use) is to use macros to apply the style and reapply/restart/continue lists. Most of these macros have appeared on this forum in the past. Here are some threads that will give you an idea on how people have dealt with the macros - some of which could be adapted to define the style attributes. If you do a search on some of the keywords you will find plenty of others.
    Consistent Numbering
    Restarting Numbering

    This code would define the numbering attributes for a series of styles. It will also create the styles for you if they don't already exist in the document. - <post#=25250>post 25250</post#>
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  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: Create Styles Macro & ContinuePreviousList (20

    Andrew,

    thank you. I am sure the macro used to set the styles to renumber but perhaps old age is creeping on. In theory you are right about the Level 2 appraoch which I used to use a long time ago; I abandoned it as it has the drawbacks you mention, however on reflection now I wonder if this is the best approach, given there is no proper alternative. I don't use Normal but my main bodytext style would almost always be between lists somewhere since it is the one following Headings and most commonly used. I will reconsider this. One question, since I haven't tried this before and I'm unclear what you meant by "you will be restricted to only one numbering pattern "... can I used the same style e.g. Normal as a level one in more than one list template?

    Since you question the approach - and I've seen you say it before I'll explain my reasons: I have this styles creation macro because I recreate my templates for every new release of Word. perhaps over the top now but in the early days it seemed a good precaution and I have maintained the habit. Also remembering all the styles and small, little-used, fixes is easier if captured in code. Since I am also freelance and often needing new templates for a new client I find this the most consistent way of producing a clean template without any "hidden" history, if you know what I mean.

    thank heavens for woodys lounge.................... liz

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create Styles Macro & ContinuePreviousList (20

    Hi Liz:
    I don't know if this will help, but I use the attached macro for lists such as the ones you mention. It will restart numbering without changing the style because it's not linked to any style. Of course, if you're cutting & pasting lists, you will get spaghetti numbering unless you rerun the macro on the selected list.
    Hope this helps,
    Attached Files Attached Files

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Create Styles Macro & ContinuePreviousList (20

    Where I said you would be restricted to one numbering pattern I meant that if you wanted to have two separate numbering options then the method wont work.
    eg You want the authors to be able to create lists that are numbered 1., 2., 3. etc and a separate stream to be alphabetic a. b. c. etc. If you set up the first outline list using Normal as the top level then you won't be able to also set up the next outline list the same way. If you attempt to do this you will break the first stream.

    I can empathise with your reasoning for ensuring you end up with consistent styles but I would have thought that the enormous number of parameters which must be fiddled to tailor each style to just the way you want them would make for thousands of lines of code. I know in my templates I would typically have 50+ paragraph styles. This number becomes huge primarily because of the style series such as TOC, Heading, List Bullets, List Numbers, List Alphas, Annexes, Attachments - any of which may have up to nine members in the series. I find the creation and modification of styles is far easier when I can see the results immediately and can tweak style attributes in a template in real time rather than needing to also modify the code for future reuse.

    The code you rely on is going to be partly version specific too since the latest versions of Word also have new style types (Lists, Tables) which gracefully degrade when stepping backwards a version but will cause errors if defined in code. I would expect some of the paragraph and character attributes available have also grown through the version history of Word too - not that I can think of anything new there.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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