0

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
Community
  • 1
  • 1
C-Love511
  • 358
  • 1
  • 7
  • 24

1 Answers1

2

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.

Community
  • 1
  • 1
Miqi180
  • 1,670
  • 1
  • 18
  • 20
  • Okay, I see the fix--So for my education, this works because it uses an integer instead of "msoFileDialog" which is dependent on the library? – C-Love511 Sep 04 '16 at 01:38
  • The `FileDialog` object takes a parameter in the form of a an `MsoFileDialogType` constant that represents the type of dialog box, in this case the `msoFileDialogFilePicker`. Thus, the parameter is interchangeable with a number (type Long in the fix, not integer, but that's not essential). The reason the fix works is due to the first three lines of code, not just the first. See https://msdn.microsoft.com/en-us/library/office/ff196794.aspx – Miqi180 Sep 04 '16 at 01:56