Passing ListBox to function is returning a mismatch when calling the function

44 views Asked by At

I have been trying this out for a while now and I keep getting the same error of a mismatch, code is below.

Function listAvailableFiles(FolderPath As String, DropDown As ListBox)

    Dim File As String
    Dim j As Integer
    File = Dir(FolderPath & "\*.cdr")
    Do While File <> ""
        DropDown.AddItem File
        File = Dir
    Loop

End Function

Private Sub UserForm_Activate()
    Dim DimensionFolder As String
    DimensionFolder = "C:\Users\cwats\OneDrive - Watson Memorials\Watson Memorials\Designs Template and Drawings\MD UK\Memorial Shapes\Foundations"
    Call listAvailableFiles(DimensionFolder, ListDimensionFilesDropdown)
End Sub

I am assuming I am not calling the function correclty but any help on this would be greatly appreciated.

1

There are 1 answers

0
Domenic On

You'll need to change the declaration line for your function as follows...

Function listAvailableFiles(FolderPath As String, DropDown As msforms.ListBox)