Using VBA to open workbook from Sharepoint opens blank or is inaccessible from within sub

phanzom

New Member
Joined
Dec 1, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello Excel experts, first of all, thanks for this fantastic board full of advice, with which I was able to solve dozens of problems!

This is my first post, and the requirement looks easy, but then again....

I need to open an Excel file from Sharepoint and copy a range of cells to the active workbook. That being said, this must work from outside the company i.e. without authentication. For this purpose, I created a link to the file in Sharepoint that allows Anyone to open the file without signing in:

1701427338118.png


This link looks like this:

https://somecompany.sharepoint.com/...1EhOPsXXefMuUBQtOEnuYRR8vaOMfxvV7civ?e=OLW6Xs

I can open the link via VBA using:
  • ActiveWorkbook.FollowHyperlink Address:=(lnk)
and this opens the workbook, but then I can’t access the opened workbook from within the sub, getting the following Error: Script out of range, and: ‘Excel can’t do this because a dialogue box is open’. In fact, I think the link only opens AFTER the sub has finished. I tried to build in a delay, to wait for the link to open, but that does not work.

If I use
  • Workbooks.Open(lnk)
then Excel will open a blank, white page, totally empty, even without the cell borders. I have followed some advice about disabling DDE, but that didn't fix it.

1701427316884.png


If I use the regular link to the file, e.g. something like

https://somecompany.sharepoint.com/sites/Sales/Shared Documents/Projects/versionTable.xlsx?web=1

then i get a prompt to sign-in with Microsoft, which I can’t use because the users are not from our company.

So either I use use the Hyperlink approach, and learn how to access the file from a sub, or fix the Workbooks.Open approach opening the file correctly. Any help is very much appreciated.

Many thanks
phanzom
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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