Import Data from a Password-Protected Access Database into Excel
Question details
Import a table from a password-protected Access database into Excel when the Get Data connection does not prompt for the database password.

- Product
- Microsoft Excel and Microsoft Access
- Device & OS
- not provided
- Scenario
- The user wants to retrieve data from an encrypted Access database into an Excel worksheet.
- Observed behavior
- Excel's Get Data connection may fail without offering a prompt for the Access database password.
Confirm the database file path, database password, and name of the table to import. For the VBA method, check that a compatible Microsoft Access Database Engine provider is installed and matches the bitness of Excel.
Import the Access table with an ACE OLE DB connection in Excel
Use Excel VBA to supply the database password in a connection string and copy a table into the active worksheet.
This example uses late binding, so you do not need to add an ADO reference in the VBA editor. It writes field names to row 1 and data beginning in row 2 of the active worksheet.
In Excel, select the worksheet where you want the data, press Alt+F11, and choose Insert > Module.
Paste this macro into the module, then replace the file path and TableName with your database path and table name: Sub ImportAccessTable() Dim cn As Object, rs As Object Dim dbPassword As String, i As Long Dim ws As Worksheet Set ws = ActiveSheet dbPassword = InputBox("Enter the Access database password:") If dbPassword = "" Then Exit Sub Set cn = CreateObject("ADODB.Connection") Set rs = CreateObject("ADODB.Recordset") cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & _ "Data Source=D:\Stocks.accdb;" & _ "Jet OLEDB:Database Password=" & dbPassword & ";" rs.Open "SELECT * FROM [TableName]", cn For i = 0 To rs.Fields.Count - 1 ws.Cells(1, i + 1).Value = rs.Fields(i).Name Next i ws.Range("A2").CopyFromRecordset rs rs.Close cn.Close End Sub
Return to Excel, press Alt+F8, select ImportAccessTable, and click Run. Enter the database password when prompted.

Export the Access table to an Excel workbook
Use Access to create an Excel file when you can open the protected database directly.
Open exported Access data in WPS Spreadsheets
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. After exporting your Access data to an Excel workbook, open it in WPS Spreadsheets for a straightforward move to WPS. WPS does not resolve Excel's Access connection prompt issue.

Frequently Asked Questions
Why does Excel fail to connect without asking for the database password?
The Get Data connection may not present a database-password prompt for the encrypted Access file. An ACE OLE DB connection can supply the password through the Jet OLEDB:Database Password property.
What if Excel says the ACE provider is not registered?
Check that the Microsoft Access Database Engine is installed and that its bitness matches Excel. In Excel, check the installed Office bitness under File > Account > About Excel.
Can I import an Access query instead of a table?
Yes. In the VBA example, replace TableName in the SELECT statement with the name of the saved Access query, keeping the square brackets around the name.
Will the exported Excel file update when the Access data changes?
No. An Access export creates a separate copy. Run the export again to obtain updated data, or rerun the Excel VBA import.




