Search code examples
excelfiledialogvba

msoFileDialogFilePicker resulting in error


Please don't comment with anything about naming conventions, approaches, asking what the code is supposed to DO, or anything that isn't directly related to my issue:

This runs perfectly for me, everytime--A window pops up, and I select multiple Excel files and their data is uploaded into my sheet (Code not pictured). My client says he gets an error when he runs it, and naturally I assumed it was because he ran it on a Mac...but he says he gets the error on both PC and Mac. I can't recreate the error...and here we are.

Here's the code in question, the erring line highlighted in yellow: enter image description here

enter image description here

Code for your copying:

Sub Import_Employee_Sheet()
    With Application.FileDialog(msoFileDialogFilePicker)
        .AllowMultiSelect = True

        If .Show = True Then
        End If
    End With
End Sub

Solution

  • This is probably because he hasn't set the Microsoft Object [Version number] Library reference under Tools/References in the IDE, or because it's broken. Also see this post on how to fix the problem WITHOUT setting the object reference in order to avoid similar problems in the future.

    Edit

    It should read "...without setting the library reference" above.