How to dynamically set password for entire excel workbook?

I want to dynamically set password for the entire workbook without using third party activities

Hi @May_Prince

We can do this with invoke VBA and excel applications scope like this


Here is the txt doc

Sub SetWorkbookPassword()
Dim strPassword As String
strPassword = "yourpassword"
ActiveWorkbook.Password = strPassword
End Sub


it is working if only the excel is open. It should work without opening …Please help

Kindly uncheck the visible property



I have unchecked and tried it is showing this error

I have deleted the file and only tried it as new file still this issue is there

That is because you already assing the password, so you have to fill the password in order tor ead it correctly again


Even if i am trying to creating the new file still I get the same error