Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Get Word heading style number font (VBA/Word 2000)

    I would be grateful if someone could help with this before I go completely insane. What I want to do is obtain the name of the font used for the number in a heading style (e.g. "Heading 1").

    'With this, I can get the font properties of heading style text

    With ActiveDocument.Styles("heading 1")
    With .Font
    MsgBox (.Name)
    '...
    End With
    End With


    'With this, I can get non-font properties of heading style numbers

    With ListGalleries(wdOutlineNumberGallery).ListTemplate s(1).ListLevels(1)
    MsgBox (.StartAt)
    '...
    End With


    'Using the same successful calls and syntax used in the examples above, I can get font properties of heading style numbers except for the font name. Am I doing something stupid here is Word known not to reveal what I seek?

    With ListGalleries(wdOutlineNumberGallery).ListTemplate s(1).ListLevels(1)
    With .Font
    MsgBox (.Name)
    MsgBox (.Italic)
    '...
    End With
    End With

    Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Get Word heading style number font (VBA/Word 2000)

    If ListGalleries(wdOutlineNumberGallery).ListTemplate s(1).ListLevels(1).Font.Name is an empty string, this list level uses the font of the heading style. Only if the font for the list level has been set explicitly, .Font.Name will return the name of that font.

  3. #3
    New Lounger
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get Word heading style number font (VBA/Word 2000)

    Thanks Hans but I am afraid that it still doesn't work for me even if the font is explicitly set for the list level. Does it work for you?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Get Word heading style number font (VBA/Word 2000)

    It works for me, but I'm using Word 2002 (aka XP). I wouldn't have expected that to make a difference, though.
    Are you sure you are referring to the correct list template? The behavior of list templates is notoriously quirky.
    What happens if you run the following code?

    Sub Test()
    With ListGalleries(wdOutlineNumberGallery). _
    ListTemplates(1).ListLevels(1).Font
    .Name = "Comic Sans MS"
    MsgBox .Name
    End With
    End Sub

    PS Welcome to Woody's Lounge!

  5. #5
    New Lounger
    Join Date
    Jan 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get Word heading style number font (VBA/Word 2000)

    Hans, you are right on the money! I was referring to the wrong list template though I was aware of the minefield that stands for Word's list numbering.

    Thanks also for the welcome to the Lounge.

    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
  •