How do you populate a list of Sharepoint Files in A combobox

thardin

Board Regular
Joined
Sep 29, 2021
Messages
137
Office Version
  1. 365
Platform
  1. Windows
I have this code to download a file from sharepoint that works Wonderfully!
Now I just want to be able to select a file from a dropdown combobox list that contains all the files to choose from the Sharepoint URL.
Any ideas how this can be done? (kind of like displaying files in a folder location, but a sharepoint url instead)
I asked ChatGPT and it uses a JSONConverter feature that doesn't work!.
Thank you.


VBA Code:
Sub DownloadFromSharePoint()
    Dim sharePointURL As String
    Dim FilePath As String
    Dim fileName As String
    Dim FullPath As String
    
    ' SharePoint URL
    sharePointURL = "https://......sharepoint.com/sites......../"
    
    ' File path on SharePoint (including folder structure)
    FilePath = ""
    
    ' File name
    fileName = "test.xlsx" 
    
    ' Full path on SharePoint
    FullPath = sharePointURL & FilePath & fileName
    
    ' Download workbook from SharePoint
    Workbooks.Open FullPath
    
    MsgBox "Workbook downloaded from SharePoint successfully!", vbInformation
End Sub

Sub DisplayFilesInFolder()
    Dim folderPath As String
    Dim folder As Object
    Dim file As Object
    
    ' Specify the folder path
    folderPath = "C:\Users\233166\Desktop\Macro WBs\Backup"
    
    ' Create a FileSystemObject
    Dim fs As Object
    Set fs = CreateObject("Scripting.FileSystemObject")
    
    ' Get the folder object
    Set folder = fs.GetFolder(folderPath)
    
    ' Loop through each file in the folder and display the file names
    For Each file In folder.Files
        Debug.Print file.Name
    Next file
End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,215,076
Messages
6,122,984
Members
449,092
Latest member
Mr Hughes

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