Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Custom Numbering scheme with chapter numbers (Win 2k, Word 2k)

    Good morining
    I have a need to produce a customised numbering scheme for the basic list numbering.

    I would like to prefix each list number with a number derived from a stored document property.

    This will allow the creation of a manual from separate files (chapters). The chapter number will be supplied via custom form whic captures a varierty of custom properties.

    Hence list numbered item 23 in chapter 5 = 5.23

    My original thought was to crate a style but ..

    how to programmitically concatenate a doc property field to the list number item .. ?

    Any ideas welcome.

    Cheers
    Geof

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Custom Numbering scheme with chapter numbers (Win 2k, Word 2k)

    Geof,

    I played around a little with this. Have the components and I hope you can put this together. Should be easy but I don't have the time right now to put together and test it.

    To get at custom properties:
    Gary Frieder's post #78646 showed how to add a custom property and test to see if it exists. Using his second routine, you can modify it to search for a property of a given name. When/if you find it (there should be no if given that you're adding these by the form), you can set a variable equal to the property's value by just using something like:
    var = objCustDocProps(i).Value

    Now with that in hand, I recorded a macro of creating an outline list. The beginning of this is as follows:
    <pre> With ListGalleries(wdOutlineNumberGallery).ListTemplate s(2).ListLevels(1)
    .NumberFormat = "%1."
    .TrailingCharacter = wdTrailingTab
    .NumberStyle = wdListNumberStyleArabic
    .NumberPosition = InchesToPoints(0)
    .Alignment = wdListLevelAlignLeft
    .TextPosition = InchesToPoints(0.25)
    .TabPosition = InchesToPoints(0.5)
    .ResetOnHigher = 0
    .StartAt = 1
    With .Font
    .Bold = wdUndefined
    </pre>


    Now assuming the value of the custom property is in var, per above, you can change the .NumberFormat statement to:
    .NumberFormat = var & "%1."

    This part (concatenating a string with the %1) I did test and it works fine. I would think it would not matter how var gets its value.

    There is a lot more code that Word generates when recording a macro of starting a list, so be careful here. It goes thru all 9 list levels and initializes lots of properties.

    Hope this gets you going. Good Luck.

    edited: forgot to mention this was for word 2000.


    Fred

  3. #3
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts

    Re: Custom Numbering scheme with chapter numbers (Win 2k, Word 2k)

    Hi Fred
    Thanks for the tip,

    In the end it was simple ..

    Sub resetNum()
    Dim strTst As Variant
    Dim chapter As String
    'Clue from Fred and Gary
    chapter = ActiveDocument.CustomDocumentProperties("chapter")

    With ListGalleries(wdNumberGallery).ListTemplates(1).Li stLevels(1)
    .NumberFormat = chapter & "-" & "%1."
    .ResetOnHigher = 0
    .StartAt = 1
    .LinkedStyle = ""
    End With
    ListGalleries(wdNumberGallery).ListTemplates(1).Na me = ""
    Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
    wdNumberGallery).ListTemplates(1), ContinuePreviousList:=False, ApplyTo:= _
    wdListApplyToWholeList, DefaultListBehavior:=wdWord9ListBehavior

    End Sub

    Teh custom property is created and populated from the form ..

    When I grab Gary's function to test for existence of customproperty "chapter" & check that it is >= 1 problem is solved.

    This means that a portion of the list can be selected and renumbered at will.

    Thanks again

    Geof

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Custom Numbering scheme with chapter numbers (Win 2k, Word 2k)

    Hi Geof,

    No problem. I think the key was Gary's code showing how to use custom properties (a rarely used feature from what I know that seems pretty powerful). Even though I think it was a little overkill for your project since you had already created the property, it sounds like you were able to trim it down for your purpose.

    You mentioned:
    >>When I grab Gary's function to test for existence of customproperty "chapter" & check that it is >= 1 problem is solved.

    I saw where you were getting the value of "chapter" but didn't see where you were testing it to see if it's >=1. Was that done somewhere else?

    Fred

Posting Permissions

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