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

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Custom Numbering scheme with chapter numbers (Win 2k, Word 2k)

    • This topic has 3 replies, 2 voices, and was last updated 23 years ago.
    Author
    Topic
    #371147

    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

    Viewing 0 reply threads
    Author
    Replies
    • #589353

      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:

          With ListGalleries(wdOutlineNumberGallery).ListTemplates(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
      

      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

      • #589473

        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).ListLevels(1)
        .NumberFormat = chapter & “-” & “%1.”
        .ResetOnHigher = 0
        .StartAt = 1
        .LinkedStyle = “”
        End With
        ListGalleries(wdNumberGallery).ListTemplates(1).Name = “”
        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

        • #589495

          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

    Viewing 0 reply threads
    Reply To: Custom Numbering scheme with chapter numbers (Win 2k, Word 2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: