Retrieve Data from a Password-Protected SharePoint Excel Workbook with VBA
Question details
Determine how to retrieve values from a password-protected Excel workbook stored on SharePoint without displaying prompts or opening it interactively.

- Product
- Microsoft Excel VBA and SharePoint
- Device & OS
- not provided
- Scenario
- A VBA process needs data from a protected workbook stored at a SharePoint location.
- Observed behavior
- Standard VBA worksheet references cannot reliably read an encrypted workbook without opening or decrypting it, and SharePoint access requires authentication.
Confirm that you have SharePoint permission and, if the file is encrypted, the authorized workbook password. In Excel, check File > Info > Protect Workbook to distinguish password encryption from worksheet or workbook structure protection.
Open the SharePoint workbook through VBA with authorized access
Use this approach when the workbook is encrypted and your VBA process is allowed to open it.
Excel must open and decrypt an encrypted workbook before VBA can read its worksheet values. Supplying a workbook password does not replace SharePoint authentication, and a prompt-free run is not guaranteed.
Open the workbook from its SharePoint document library in Excel and sign in with an account that has permission to read it.
In the VBA editor, use Workbooks.Open with the SharePoint file path or URL. If the workbook is encrypted, supply its authorized password through the Password argument using an organization-approved secure process; do not hard-code it in the macro.
Read the required cells through the opened workbook's Worksheets and Range objects, then call the workbook's Close method when finished.

Use an approved SharePoint data integration
Consider an integration when the goal is to retrieve data without opening the workbook interactively in Excel.
Work with Excel-Compatible Spreadsheets in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface for everyday spreadsheet work. Its Excel format compatibility can help with migration, although it does not resolve Microsoft Excel VBA or SharePoint authentication issues.

Frequently Asked Questions
Can VBA read an encrypted workbook without opening it?
Standard VBA worksheet references cannot reliably read an encrypted workbook without opening or decrypting it. Use Workbooks.Open with authorized access, or investigate an integration that explicitly supports your source.
Does the workbook password also grant SharePoint access?
No. The workbook password and SharePoint permissions are separate. Sign in to the SharePoint site with an account that can access the file, and provide the workbook password if the file is encrypted.
Can Power Query import a password-encrypted workbook?
Support depends on the connector and source. Check Data > Get Data for the available SharePoint connectors and verify whether the selected connector supports the workbook's encryption before designing the workflow around it.
Can I prevent every prompt when opening the workbook with VBA?
Not necessarily. Supplying the Password argument to Workbooks.Open can address the workbook password, but SharePoint authentication or organizational security policies may still require interaction.
Is worksheet protection the same as file encryption?
No. Worksheet or workbook structure protection restricts certain changes, while file encryption can require a password to open the workbook. Check File > Info > Protect Workbook in Excel to identify the protection in use.




