none
Programmatically change font size for numbered lists RRS feed

  • Question

  • We have some forms that must be created using 14 point.  The majority of the time, they need to be in 12 point.  Therefore, the templates are created in 12 point.  There is a vba macro that simply, when run, changes the NORMAL font to 14 point.  It works for every style, except LIST NUMBER.  We have built a couple of other list styles, i.e. Tab Number.  All settings are identical in the list styles (with the exception of the wrap).  The macro changes the font for the NUMBER with the macro to match the font of the text.  It does NOT work, however, for the List Number style.  The only difference I can think of is that List Number is a built in style; whereas, Tab Number is not.

    Is there in vba to change the font for the number when the macro is run.  I tried to record the macro and then look at it, but it uses Selection attribute and changes the current paragraph to List Number style.  I want the font size changed regardless of where the cursor is.

    Thursday, January 31, 2013 12:47 AM

Answers

  • Hi orlandp

    On my system (where I haven't changed style definitions) changing the font of the Normal style works fine: it changes the font displayed for List Number (and List Paragraph), numbers as well as text.

    But what I do see, with List Number, is that as soon as I make a manual change to the number (click on the number, change the font), this stops working and I don't see any way to make it revert, short of starting with a new document (assuming the manual change hasn't been saved back to Normal.dotm).

    Which version of Word are you working with?

    And no, there does not appear to be a way to change the font of the number using the object model (although SendKeys might work, but is unreliable, at best).

    I'd say, use a different style...


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, January 31, 2013 8:46 AM
    Moderator
  • The following should work:

    Dim lt As ListTemplate
    'Set a reference to a list template object
    'in this simple example I have NOT tested
    'to make sure that there is a list at the insertion point
    Set lt = Selection.Range.ListFormat.ListTemplate
    lt.ListLevels(1).Font.Size = 12
    End With

    Of course, copying in a fresh version of List Number from a newly generated Normal.dotm might be easier.


    Stefan Blom, Microsoft Word MVP

    Thursday, January 31, 2013 9:37 AM
  • I ended up recreating the template/styles from scratch and now it works fine.
    Tuesday, February 19, 2013 6:54 PM

All replies

  • Hi orlandp

    On my system (where I haven't changed style definitions) changing the font of the Normal style works fine: it changes the font displayed for List Number (and List Paragraph), numbers as well as text.

    But what I do see, with List Number, is that as soon as I make a manual change to the number (click on the number, change the font), this stops working and I don't see any way to make it revert, short of starting with a new document (assuming the manual change hasn't been saved back to Normal.dotm).

    Which version of Word are you working with?

    And no, there does not appear to be a way to change the font of the number using the object model (although SendKeys might work, but is unreliable, at best).

    I'd say, use a different style...


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, January 31, 2013 8:46 AM
    Moderator
  • The following should work:

    Dim lt As ListTemplate
    'Set a reference to a list template object
    'in this simple example I have NOT tested
    'to make sure that there is a list at the insertion point
    Set lt = Selection.Range.ListFormat.ListTemplate
    lt.ListLevels(1).Font.Size = 12
    End With

    Of course, copying in a fresh version of List Number from a newly generated Normal.dotm might be easier.


    Stefan Blom, Microsoft Word MVP

    Thursday, January 31, 2013 9:37 AM
  • I ended up recreating the template/styles from scratch and now it works fine.
    Tuesday, February 19, 2013 6:54 PM
  • I ended up recreating the template/styles from scratch and now it works fine.
     
     
    Thank you for the follow-up!

    Stefan Blom, Microsoft Word MVP
    Tuesday, February 19, 2013 7:34 PM