Data Protection Issues

How to Find Password-Protected Excel Files in a Folder

Anum MushtaqAnum Mushtaq Nov 3, 2026 869 views

Question details

The user needs a method to scan a folder containing hundreds of Excel workbooks to identify which specific files are password-protected.

How to Find Password-Protected Excel Files in a Folder
Product
Excel
Device & OS
not provided
Scenario
Managing a large directory of Excel files where manually checking each file for password protection or encryption is too time-consuming.
Observed behavior
Instead of manually opening each workbook, an automated process is required to detect and log files that have file-level encryption, workbook protection, or worksheet protection.
Before you start

Before running any automation scripts, ensure all Excel workbooks in the target folder are closed to prevent read/write conflicts, and clarify whether you are looking for file-level encryption (requires password to open) or structural protection.

Solution 1Recommended

Use a VBA Macro to Automate File Scanning

Use an Excel VBA script to automatically loop through all workbooks in a folder, attempt to open them, and log the ones that trigger a password prompt.

Because Excel does not natively expose password protection status in Windows File Explorer metadata, the most reliable way to identify encrypted files is by automating the process of opening them.

A VBA macro can be programmed to quietly open each file using a dummy password. If the file opens successfully, it is unprotected. If an error is returned, it means the file is password-protected, and the macro can record its name before moving to the next file.

1
Open the VBA Editor

Launch Excel, open a new blank workbook, and press 'Alt + F11' on your keyboard to open the Microsoft Visual Basic for Applications (VBA) editor.

2
Insert a New Module

In the VBA editor, click on 'Insert' in the top menu bar, and then select 'Module'. This will open a blank code window.

3
Create the Scanning Script

Paste or write a macro script utilizing the 'Dir' function to loop through your target folder path. Use the 'Workbooks.Open' method with a 'Password:="DummyPassword"' argument and utilize 'On Error Resume Next' to catch files that fail to open.

4
Run the Macro

Press 'F5' or click the 'Run' button. The macro will scan the folder, testing each file. The process may take a few minutes depending on the number of workbooks.

5
Review the Output

Have your macro output the names of the protected files into column A of your active worksheet so you can easily identify them.

Use a VBA Macro to Automate File Scanning
Execution Speed: This process may be slow because the automation tool must physically open and close every single workbook in the directory to verify its protection status.
Manage protected files efficiently

Manage and Automate Encrypted Spreadsheets with WPS Office

WPS Spreadsheet provides robust macro support and built-in document encryption tools, making it easy to automate folder scans and manage thousands of password-protected workbooks efficiently.

  1. 1. Install WPS Office: Download and install WPS Office, which includes the highly compatible WPS Spreadsheet application.
  2. 2. Access Developer Tools: Open WPS Spreadsheet, go to the 'Developer' tab, and open the VBA Editor to input your folder-scanning macro.
  3. 3. Execute Batch Scans: Run your macro to efficiently loop through your directories and identify password-protected files.
  4. 4. Manage Passwords Easily: For identified files, quickly update or remove security settings by navigating to 'Menu' > 'Document Encryption' in WPS Spreadsheet.
Fully compatible with Microsoft Excel formats (.xlsx, .xls, .xlsm)Supports VBA macros for advanced batch processing and automationAdvanced built-in document encryption and permissions managementLightweight architecture ensures fast loading of large directories
QA img-9

Frequently Asked Questions

Can I detect password-protected Excel files without opening them?

Generally, no. Because file-level encryption scrambles the file data, external tools and scripts must attempt to open the workbook to definitively trigger the password prompt or read the internal protection flags.

What is the difference between file encryption and workbook protection?

File encryption requires a password simply to open and view the document. Workbook protection, on the other hand, allows anyone to open and view the data but requires a password to make structural changes, such as adding, deleting, or hiding worksheets.

Why does my macro run slowly when scanning a folder?

Scanning a folder for passwords requires the macro to initiate the application's open and close commands for every single file. With hundreds of workbooks, the computer needs time to allocate memory and load each file structure, causing the process to take several minutes.

Does WPS Office support VBA for folder automation?

Yes, advanced versions of WPS Office fully support VBA macros. You can write, edit, and execute scripts to scan folders, manage files, and automate repetitive data tasks with high compatibility.