How to query an Excel file on SharePoint using VBA / ADO / Other

Jon73

New Member
Joined
May 25, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
I have a system that currently operates on a network folder very well, but I am exploring transferring this to Sharepoint mostly for ease of access and regional VPN / network folder issues
So far everything I've tested works well, but I have some queries that operate out of the main excel front end of the system for doing things like checking user permissions, etc.
These details reside in a file that currently reside in the network folder but I intend to move to sharepoint
In the network folder I can query the file as follows, easy....it works fine!

Set connection = CreateObject("ADODB.Connection")
With connection
.Provider = "Microsoft.ACE.OLEDB.12.0"
.ConnectionString = "Data Source=" & strPro & "\" & "TheFile.xlsx" & ";" & _
"Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
.Open
End With

But! the connection to a sharepoint folder falls flat on its face when it tries to open the connection

Set connection = CreateObject("ADODB.Connection")
With connection
.Provider = "Microsoft.ACE.OLEDB.12.0"
.ConnectionString = "Data Source=" & "\\companyname.sharepoint.com\sites\Sitename\Folder1\Folder2\Folder3\TheFile.xlsx" & ";" & _
"Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
.Open
End With

After this point I have some SQL to pull back a limited recordset for evaluation

I have searched far and wide for some code that works to query an excel file on sharepoint
I can even open the sharepoint file using VBA no problems but I can't query it unless I use power query which will add many steps and slow things down.
Is it even possible? Is there a completely different way?
I expect there is something special in the connection string that I'm missing

Thanks for any help!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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