Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling bullets with code

Status
Not open for further replies.

Phil5673

Programmer
Sep 30, 2002
42
US
How are bullets turned on/off with VBA code. I have been looking in the Word help for this and cannot seem to find it. Thanks for the help.

Phil Edwards
 
The macro recorder created the following code. I'm sure it can be streamlined.

Code:
With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
        .NumberFormat = ChrW(61623)
        .TrailingCharacter = wdTrailingTab
        .NumberStyle = wdListNumberStyleBullet
        .NumberPosition = InchesToPoints(0.25)
        .Alignment = wdListLevelAlignLeft
        .TextPosition = InchesToPoints(0.5)
        .TabPosition = InchesToPoints(0.5)
        .ResetOnHigher = 0
        .StartAt = 1
        With .Font
            .Bold = wdUndefined
            .Italic = wdUndefined
            .StrikeThrough = wdUndefined
            .Subscript = wdUndefined
            .Superscript = wdUndefined
            .Shadow = wdUndefined
            .Outline = wdUndefined
            .Emboss = wdUndefined
            .Engrave = wdUndefined
            .AllCaps = wdUndefined
            .Hidden = wdUndefined
            .Underline = wdUndefined
            .Color = wdUndefined
            .Size = wdUndefined
            .Animation = wdUndefined
            .DoubleStrikeThrough = wdUndefined
            .Name = "Symbol"
        End With
        .LinkedStyle = ""
    End With
    ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
    Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
        wdBulletGallery).ListTemplates(1), ContinuePreviousList:=False, ApplyTo:= _
        wdListApplyToWholeList, DefaultListBehavior:=wdWord10ListBehavior
    Selection.TypeParagraph
    Selection.Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph
 
It is very bizarre. You can turn off bullets on a selection with:
Code:
Selection.Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph

You can turn them on with:
Code:
   Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
      wdBulletGallery).ListTemplates(1)

That being said, there is some mighty strange things going on with this part of the object model. If you run the ON code first it seems "reasonably" clear - you are applying a list template from a listgallery of bullets. OK, but to remove those same bullets you remove numbering.

Huh? But there it is.

Also, while there is a wdSimpleNumering property, if you simply number paragraphs, they are assumed to be OutlineNumbering. There is a property called ListMixedNumering that I have not been able to get a coded return for. it must be in there somewhere....

Note that while there is a ListType, as in:
Code:
selection.Range.ListFormat.ListType
it is read only. You can not directly change a paragraph (using its range) ListType. You can only remove it, and apply something else.


Gerry
See my Paintings and Sculpture
 
Yes, it is very bizarre. To both of you, thanks for your help.

Phil Edwards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top