VBA uses dialog box to allow choice of folder then allows multi selection of all files in sub folder and open into one excel spreadsheet

bgrove

Board Regular
Joined
Dec 2, 2013
Messages
60
Hi,
I have researched the internet for three day and pieced together this code that gives me a dialog box and shows sub foder on sharepoint but when I select the sub folder to open it the dialogox shows zero files. There is message that appears There are no documents of the specified type in this document library.

When I manually navigate to the sharepoint folder there ARE 25 excel files. Very frustrated!

Here is my code. I would love some help..... Thank you in advance Bev

P.s. I have not gotten to the code that opens all selected files into one work sheet. I'm trying to solve one issue at a time.

Sub test3()


Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Dim vrtSelectedItem As Variant
With fd
.InitialFileName = "https://microsoft.sharepoint.com/teams/folder A/Folder B/ Folder C/"
.Title = "Select files"
.AllowMultiSelect = True
.ButtonName = "Confirm"

If .Show = -1 Then
'ok clicked'
For Each vrtSelectedItem In .SelectedItems
MsgBox vrtSelectedItem
Next vrtSelectedItem
Else
'Cancel Clicked'
End If
End With
''Set the object variable to nothing.
'Set fd = Nothing


End Sub
 
Last edited:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Bev try adding in a filter option if it is only the excel workbooks you want to see.

.Filters.Add "Excel", "*.xls;*.xlsm; *.xlsx", 1
 
Upvote 0

Forum statistics

Threads
1,223,727
Messages
6,174,144
Members
452,547
Latest member
Schilling

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top