Question : How do I update a powerpoint userform listbox from excel?

I have a userform in powerpoint that pulls data from an excel workbook. There is a listbox that get's filtered based on the users criteria. I need to pull data in to a userform multi-column listbox:
Name, which is visible
ID, which is invisible.

I can do this in excel from another workbook, but when I try to go across applications, the macro breaks. Currently, i am just adding a single column (which works fine), but this needs to change to a multi column selection.

Any suggestions, references, etc are most welcome.

Thanks.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
Sub PrePopulate()
 
On Error GoTo errHandler
    
        Set objExcel = CreateObject("Excel.Application")
        objExcel.Visible = False
        
        Set MyPresentation = Presentations(1)
        
        Set objWorkbook = objExcel.Workbooks.Open(MyPresentation.Path & "/" & LOCALXLAPATHNAME)
        
        'Runs excel procedure to pull in data from DB
        objExcel.Run "GetData"
             
    'Pulls in data from excel and populates the listbox
    'This is where I would like to change the code so that it pulls in the row source data from excel.
    Set objWorksheet = objWorkbook.Worksheets("Funds")
    frmDimPres.lbFunds.Clear
         
        For Each rngItem In objWorksheet.Range("dnrFundListlabel")
            frmDimPres.lbFunds.AddItem (rngItem.Text)
        Next rngItem
         
errHandler:
 
End Sub

Answer : How do I update a powerpoint userform listbox from excel?

yeah you're right...Thanks!

So that will make the code look like this:

Sub PrePopulate()
    Dim LOCALXLAPATHNAME
    Dim MyPresentation
    Dim varList
   
    On Error GoTo errHandler

    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = False
   
    Set MyPresentation = Presentations(1)
    Set objWorkbook = objExcel.Workbooks.Open(MyPresentation.Path & "/" & LOCALXLAPATHNAME)
   
    'Runs excel procedure to pull in data from DB
    objExcel.Run "GetData"
   
    Set objWorksheet = objWorkbook.Worksheets("Funds")
   
    'Fill lbFunds with data
    varList = objWorksheet.Range("dnrFundListlabel").Value
    With lbFunds
       .ColumnCount = 2
       .List = varList
    End With
         
errHandler:
End Sub
Random Solutions  
 
programming4us programming4us