Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Aug 2002
    Location
    Geelong, Victoria, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting Include Heading Level No. setting in Word (Word 9.0)

    I used to have some very useful WordBasic macros that I am now in the process of converting to VBA. Most of the code converts to VBA well but I am stumped with how to get the setting for including the number of the previous heading level for a nominated built-in heading style.

    For example, if the Heading1 style uses Arabic numbering (e.g. 1, 2, 3), I want to be able to determine whether the Heading2 style is set include the number of the Heading1 style in its numbering (e.g. 1.1, 1.2, 1.3, 2.1, 2.2, 2.3).

    This was done with the Include parameter in Wordbasic. The converted (to VBA) code looks like thisL

    'Get include value from H2
    Dim FHN As Object: Set FHN = WordBasic.DialogRecord.FormatHeadingNumber(False)
    FHN.Level = 2
    WordBasic.CurValues.FormatHeadingNumber FHN
    H2IncludePreviousNumber = FHN.include
    .
    .
    .
    'Set include value for H2
    WordBasic.FormatHeadingNumber include:=H2IncludePreviousNumber

    Interestingly, while I cannot retrieve the include value I can set it using the above method.

    I am quite happy to relinquish the old Wordbasic code but I cannot for the life of me find out how to do what I want with VBA.

    All suggestions gratefully accepted.

  2. #2
    New Lounger
    Join Date
    Aug 2002
    Location
    Geelong, Victoria, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting Include Heading Level No. setting in Word (Word 9.0)

    On reflection, I could have asked my question a little more clearly.

    What I want to know is, using VBA, how can you extract from a nominated heading style whether that heading level is set to have the numbers of preceding heading levels added to it.

    That is, what is the setting that specifies that the Heading 2 style should include the number of the Heading 1 style? This isn't a particular number or a numbering style but a Yes or No to include numbering from a previous level.

    The Microsoft advice on equivalent Wordbasic - VBA functions says that you should use "ListGalleries(WdListGalleryType).ListTemplates(nu m).ListLevels(num)" in place of the old Wordbasic FormatHeadingNumber command but I can't see how it can provide what I want.

    I would be really glad if someone could solve this for me.

    Cheers.

  3. #3
    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: Getting Include Heading Level No. setting in Word (Word 9.0)

    Hi,

    In Word, click on Bullets and Numbers, click on the Outline numbering tab, choose a numbering scheme and click customize. In that dialog, click the More button and look at the bottom of the dialog. There is an ambiguously named checkbox: Legal style numbering

    Check that and the number will be attached to the previous level number.

    Hope this is the hint you were looking for,
    Kim

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

    Re: Getting Include Heading Level No. setting in Word (Word 9.0)

    The VBA versions of Word allow you more flexibility with your lower level numbering so a simple boolean won't be enough on the levels lower than 2.

    This code will return the included numbering for Heading 2
    Debug.Print ActiveDocument.Styles("Heading 2").ListTemplate.ListLevels(2).NumberFormat

    In your sample this would return a string "%1.%2" where %1 is the Heading 1 number. You can run a function over this string to return a boolean value if you wish.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #5
    New Lounger
    Join Date
    Aug 2002
    Location
    Geelong, Victoria, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Getting Include Heading Level No. setting in Word (Word 9.0)

    Many thanks Kim and Andrew. I will give them a try.

    Cheers.

Posting Permissions

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