
If Right(wb.Name, 3) = "xls" Or Right(wb.Name, 4) = "xlsx" Or Right(wb.Name, 4) = "xlsm" ThenĪctiveWorkbook.SaveAs Filename:=, Password:=" yourpassword"Įxcel VBA – Remove password to all Excel workbook in folder Set FSO = CreateObject("Scripting.FileSystemObject")įolderPath = "C:\Users\WYMAN\Desktop\excelfolder" Public Sub addPassword()ĭim folder As Object, subfolder As Object The below Procedure adds password “yourpassword” to all Excel under folder C:\Users\WYMAN\Desktop\excelfolder and all subfolders one level down. If you fail to run FSO Object, open VBE (ALT+F11) > Tools > References > Check the box Microsoft Scripting RuntineĮxcel VBA – Add password to all Excel workbook in folder You should be able to run FSO in Excel 2013.

I will base on these two posts to write the Macro. I have also written a post that explains how to loop through folders and subfolders.Įxcel loop workbooks in folders and subfolders with FSO Previously I have written another post that demonstrates how to add password to Excel using VBA. This tutorial demonstrates how to add password to all workbooks in a specified folder. If you have a lot of workbooks to add password, it is definitely a waste of time. In many organizations, employees are required to add password to Excel before sending workbooks through email, or before putting workbooks in network drive. Protect VBA code with password Add password to all Excel workbook in folder If that doesn’t work, you can use the “Extract Data” option to recover data from the file or you can try to recover the Excel file.This Excel VBA tutorial explains how to add password to all Excel workbook in folder and how to mass remove password.Įxcel VBA protect worksheet with passwordĮxcel VBA hide worksheet with password (xlVeryHidden)

Double-click the file you want to open.Alternatively, you can use the Excel keyboard shortcut Ctrl + O. Select the File tab and click on “Open” to see a list of recently opened files.When this happens, the file is often so damaged that you can no longer open it with Excel by double-clicking the file in the File Explorer. This is especially common if Excel crashes while saving the file, or if a problematic macro prevents the file from being saved correctly. The most common reason for this problem: Excel won’t open a file because the file is corrupted.
