5 Replies Latest reply: Apr 9, 2012 11:19 AM by Jonathan Dienst RSS

    How to add elements of array to listbox created by macros

      Hi Community,


      I am looking forward to add names array to listbox created.

      please its urgent requirement to be fulfilled


      Point to be noted: I dont have any sort of field by the name "names" in qvw



      sub irf1

      Dim names(100)

      Set objExcel = CreateObject("Excel.Application")


      Set objWorkbook = objExcel.Workbooks.Open _



          rowcount =2


        Do Until objExcel.Cells(rowcount,1).Value = ""   

          names(rowcount-2)=objExcel.Cells(rowcount, 1).Value

         ' msgbox(names(rowcount-2))


      '   msgbox(objExcel.Cells(rowcount, 1).Value)

         rowcount = rowcount + 1




      set LB = ActiveDocument.ActiveSheet.CreateListBox

      set BoxProp=LB.GetProperties

      BoxProp.Def.Name = "names"


      LB.SetProperties BoxProp


      end sub