Hi,
I'm new to this forum and hope for some help. Thanks in advance to the cool experts.
I would like to open a file dialog where the user can select multiple Excel files which then will be opened and values extracted into a consolidation Excel workbook. Have tried to change my code in a fileserver environment to a SharePoint equivvalent - but it doesn't work.
Sub TestSharepointFileOpen()
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Declare a variable to contain the path of each selected item. Even though the path is aString,
'the variable must be a Variant because For Each...Next routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
Dim wbBusinessCase As Workbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.InitialFileName = "\\sites\projects\"
'Use a With...End With block to reference the FileDialog object.
With fd
'Allow the user to select multiple files.
.AllowMultiSelect = True
'Use the Show method to display the File Picker dialog box and return the user's action.
'If the user presses the button...
If .Show = -1 Then
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems
Set wbBusinessCase = Workbooks.Open(vrtSelectedItem, ReadOnly:=True) 'actual command to open each file
wbBusinessCase.Close SaveChanges:=False 'close each file after it has been copied from
Next
'If the user presses Cancel...
Else
End If
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub
Bookmarks