[Solved] VBA: Creating bulleted lists in Word from VBA in Ex

  • I try to insert a bulleted list in a MS Word (2000) document from VBA Excel. I have already created the document through the VBA-code. The major problem seems to be that VBA doesn't find the ListGallery wdBulletGallery.
    Anyone who has any ideas how to solve this problem?




    Set WordApp = CreateObject("Word.Application")
    With WordApp
    .ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
    .Selection.Range.listformat.applylisttemplate listtemplate:=.ListGalleries(wdBulletGallery).ListTemplates(1), continuepreviouslist:=False, applyto:=wdlistapplytowholelist, defaultlistbehavior:=wdword9listbehavior
    .Selection.typetext Text:="Text1"
    .Selection.typeparagraph
    .Selection.typetext Text:="Text2"
    .Selection.typeparagraph
    .Selection.typetext Text:="Text3"
    .Selection.typeparagraph
    End With


    Kindly regards


    Martin

  • Try recording a macro doing what you want to do while you are in WORD. Place the WORD-recorded macro commands into your EXCEL VBA macro in the palces where you are working in the WORD document.

  • Hi e7macka and welcome,


    Have you included a reference to the Word library?


    Within the vbe in Excel go to the menu Tools > References...
    From the list select Microsoft Word 9.0 Object Libray.


    The file contains the const value for wdBulletGallery and all the other Word constants.


    Cheers
    Andy

    [h4]Cheers
    Andy
    [/h4]

  • Thank you both Tom and Andy. Now that part works as expected. This problem was solved by checking the Object Library as Andy suggested.
    Thanks for quick respons.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!