I have a use case where an Excel file is the data source, and it is sent to us password protected. I have downstream processes that expect an unlocked Excel file. I have the password.
I am looking for a way to create an unlocked version of the Excel file from the locked version using the given password, in a scripted fashion, to automate the process.
Does anyone know a way to apply the password to the Excel file and then save a new unlocked version?
If it is a "Password to Open" then the following VBS might help get you started.
' Create an Instance of Excel
Set App = CreateObject("Excel.Application")
' Load your file with given password
Set Workbook = App.Workbooks.Open("C:\path\to\your\file.xlsx",,,,"yourpassword")
' Optional - Allow Overwrite without prompt
App.DisplayAlerts = False
' Save your file, using the existing filename but reset/clear password
Workbook.SaveAs Workbook.FullName,,"",""
' Close and Quit
Workbook.Close
App.Quit
Set App = Nothing
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.