0

The below is my code. Basically it prompts the user to select files and copies them to a destination. However, I set the AllowMultiSelect = True, but the code only ever copies the first file the user selected and ignores any others. What am I missing?

With fDialog

      ' Allow user to make multiple selections in dialog box '
      .AllowMultiSelect = True

      ' Set the title of the dialog box. '
      .Title = "Please select a Video"

      ' Clear out the current filters, and add our own.'
      .Filters.Clear
      .Filters.Add "All Files", "*.*"

      ' Show the dialog box. If the .Show method returns True, the '
      ' user picked at least one file. If the .Show method returns '
      ' False, the user clicked Cancel. '

      If .Show = True Then

      ' This section takes the selected image and copy's it to the generated path'
      ' the string takes the file location, navigates to the image folder, uses the combo box selection to decide the file category, then uses the name from the filedialog to finish the path'

    FileCopy .SelectedItems(1), DLookup("Brand", "tmpDestFolders") & Dir(Trim(.SelectedItems.Item(1)))

     Else
      End If
    End With
Michael
  • 2,507
  • 8
  • 35
  • 71
  • 2
    You need to loop over the `.SelectedItems` collection, see https://stackoverflow.com/a/2158796/3820271 – Andre Jul 27 '18 at 09:25

1 Answers1

4

Loop through all selected items.

For i = 1 to .SelectedItems.Count
    FileCopy .SelectedItems(i), DLookup("Brand", "tmpDestFolders") & Dir(Trim(.SelectedItems(i)))
Next
nagarajannd
  • 715
  • 5
  • 11