Check whether excel is password protected?

Hi Team,

I want to check if the excel file is password protected, sometimes business keep password for the file and sometimes they dont, so i want to handle the excel handling (read,write) efficiently based on the scenario if there is password or if it is not? As of now am using Try catch, in the try I will try read range activity with password in the catch block I have used read range activity without password? Could anyone help me with efficient and effective approach?

Hi @kiruthiga_ganesh ,

Welcome to our Community!

You can use the ‘Invoke VBA’ activity to check whether a workbook has a password.

Function Main() as Boolean

Main = ActiveWorkbook.HasPassword

End Function
You can now use the output variable, which is a boolean, for a if activity. In case the workbook was password protected (true), you can make a workflow to insert the password.

Happy Automation!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.