tippuraj
08-01-2016, 10:34 AM
I have below code used to connect to SharePoint folder and multi-select files, however sometimes it works and sometimes it doesn't allow me to select multiple files and i can select only one file. This code works fine when i have to select files from local drive.
Any idea why "fd.AllowMultiSelect = True" works intermittently
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.InitialFileName = FileFolder & "\"
fd.InitialView = msoFileDialogViewList
fd.Filters.Add "Excel files (*.xls; *.xlsm; *.xlsx)", "*.xls;*.xlsm;*.xlsx"
fd.Title = "Choose Files from SharePoint"
fd.AllowMultiSelect = True
FileChosen = fd.Show
If FileChosen = -1 Then
For i = 1 To fd.SelectedItems.Count
dummyFile = Replace(fd.SelectedItems(i), "%20", " ")
tempfilepath = Left(dummyFile, InStrRev(dummyFile, "/"))
ActiveCell.value = "SP:File(" & Replace(dummyFile, tempfilepath, "") & ")"
ActiveCell.offset(0, 5).value = "Yes"
ActiveCell.offset(1, 0).Select
Next i
End If
Any idea why "fd.AllowMultiSelect = True" works intermittently
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.InitialFileName = FileFolder & "\"
fd.InitialView = msoFileDialogViewList
fd.Filters.Add "Excel files (*.xls; *.xlsm; *.xlsx)", "*.xls;*.xlsm;*.xlsx"
fd.Title = "Choose Files from SharePoint"
fd.AllowMultiSelect = True
FileChosen = fd.Show
If FileChosen = -1 Then
For i = 1 To fd.SelectedItems.Count
dummyFile = Replace(fd.SelectedItems(i), "%20", " ")
tempfilepath = Left(dummyFile, InStrRev(dummyFile, "/"))
ActiveCell.value = "SP:File(" & Replace(dummyFile, tempfilepath, "") & ")"
ActiveCell.offset(0, 5).value = "Yes"
ActiveCell.offset(1, 0).Select
Next i
End If