testing for password protection

H

Hakyab

Is there a way to check whether a workbook requires a password to open, prior
to opening the workbook?

What I want to do is to capture the password as the user enters it so I can
use the password for subsequent workbooks.open statements. I thought that my
module will prompt for the password, but I am not sure how this will behave
if there is no password to begin with.

Any help is appreciated, thanks.
 
J

Jacob Skaria

If you only have the open password; then supply passwords for all workbook
open statements and Excle will ignore if the workbook do not have a
password....

Dim strPassWord

strPassWord = InputBox("Enter password for your workbooks")
'workbook with password
Workbooks.Open "d:\temp.xls", Password:=strPassWord

'workbokk without password
Workbooks.Open "d:\temp1.xls", Password:=strPassWord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top