I was asked the other day on how to access with VBA a file that has a
password password protection on it so first of all I want to show you now you
can put password protection on on your your sheets so that you can't change
them or can't add any data but the most secure way to do it is is have it
encrypted so that nobody can read it unless they have the password so for
example I'm going to open my the file that has it's called password file
that's now before it opens it requires that I enter a password so i have
entered padPWD test and then I say ok and there you just have my basic file
here so let's close that down now if I open a file that I would like to I would
like to access that file so let's go to the developer and let's
go through the code so I'm basically copying from it's called the subskills
from password and this it's a source is a workbook and I'm setting the source
equals workbooks open and once again I'm using the the address from the address
bar true true means we're using it as read-only we're just we're not opening
in us we're just getting the information and then included in this line I have my
password test so that it allows me to get into the file that is password
protected and in this case it's encrypted and then I'm saying this book
this workbook activates so it copies onto my blank sheet here as opposed to
copying back into the password protected sheet and
I'm going on this worksheet range B 2 to D 3 4 . formula equals source take it
from the source sheet that is password-protected sheet 1
range a1 to C2 so let's just f8 through this so now it's opened it with
the password and so now let's go look and see see it has taken all the
information from the password protected sheet and just copied it over now it
hasn't opened it it's just that opened it in a read-only access and so there we
have how to access how to protect your sheet with a password and then how to
access a password protected sheet with your VBA code I will include this this
script in in the description please subscribe