Opening files from SharePoint using VBA breaking/running incredibly slowly

Moosles

New Member
Joined
Apr 1, 2021
Messages
24
Office Version
  1. 365
Platform
  1. Windows
I have a table in a file (that I'll call my Working file, for the purposes of this question) which lists out services and has an on/off selection for each service, similar to the below:

ServiceOn/Off
ABC1
DEF0
GHI0
JKL1
MNO1

I have a macro that runs through this list - If the service is turned off, the macro moves on to the next service; If the service is on, it picks up a file from SharePoint named Reference_XXX.xlsb, where XXX is the service (Reference_ABC.xlsb, Reference_DEF.xlsb, etc) and runs a series of processes to extract the required info from these Reference files. The idea being that these separate Reference Files can be maintained separately, and only the required info for active services would be pulled into the Working file. The opening of the Reference file from SharePoint and the extraction of the required info takes ~3 seconds.

The issue is, after the first file (which works perfectly), the macro breaks when it gets to the Workbooks.Open part of the below

VBA Code:
    sPath = "https://examplecompany.sharepoint.com/:x:/r/sites/GPF/po/WORKING/"
    sFile = sPath & "Reference_" & Service & ".xlsb"
    Workbooks.Open (sFile)

The odd thing is, that if I manually press F5 to continue the macro, it works absolutely fine, but will break at every time the loop gets to Workbooks.Open (sFile), and will again work fine if manually moved on with F5. The other odd thing is that if I delete the
VBA Code:
:x:/r/
part of the sPath address, then the macro no longer stalls, but the opening and extraction of info from the 2nd Reference file onwards now takes upwards of 90 seconds, which is unacceptably long (as there are potentially 20+ services to be added). What is going wrong here? How can I avoid the macro stalling, whilst at the same time keeping a tolerable running time? Thanks!
 

Forum statistics

Threads
1,226,847
Messages
6,193,314
Members
453,790
Latest member
yassinosnoo1

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