Name
workbook
.HasPassword
Synopsis
Returns True if a password is required to open the workbook. HasPassword
does not detect whether or not a workbook has a write password. The following code removes a password if the workbook has one:
Dim wb As Workbook, pass As String Set wb = ThisWorkbook If wb.HasPassword Then wb.Password = "" MsgBox "Password removed.", , "Password" Else MsgBox "No password found.", , "Password" End If
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.