Password protected workbook

J

JDaywalt

I have a master file that requires data feeds from multiple users. The way
it works is as follows: the user maintains their data in a separate Excel
file, then clicks a button to UPLOAD their data into the master file (which
basically opens the master file, then copies/pastes the data in). I want to
password protect the master file so no one else can make changes with the
exception of this uploaded data. How do I update my VB code to "enter" the
file password when opening the master file during this upload process, while
ensuring the user does not see or know the password?
 
M

Mike

put somthing like this after you open the master file

Worksheets(1).Unprotect "password"

put somthing like this before closing master file

Worksheets(1).Protect "password", True

and im assuming you have all cells protected
 
J

JDaywalt

Actually, it is not the workSHEET that is protected -- it is the workBOOK.
In other words, normally, when you open the master file, it tells you it can
only be opened in Read Only mode. The user would then have to do a File...
SaveAs if they wanted to save changes (the original file would remain
intact).

For this purpose, however, when the user selects the "upload" macro, I want
the master file to be opened with the password so the macro can be copy in
the user's data, and resave the file with the normal password. Does that
make sense?
 
M

Mike

ActiveWorkbook.Protect "password", True
ActiveWorkbook.Unprotect "password"
This should work the same as my other post if not post you code and I 'll
see what I can do
 
J

JDaywalt

OK, I must have something wrong or perhaps out of sequence. When the macro
attempted to open the Master File, it still prompted me for a password. Here
are the two lines of code. (MasterFile is a variable for the actual file
name; xyz is the password). Recall that when the code is initially executed,
the ActiveWorkbook is the user file, not the master. Getting closer!

Workbooks.Open Filename:=MasterFile
ActiveWorkbook.Unprotect (xyz)
 
M

Mike

Post more of your code for me

JDaywalt said:
OK, I must have something wrong or perhaps out of sequence. When the macro
attempted to open the Master File, it still prompted me for a password. Here
are the two lines of code. (MasterFile is a variable for the actual file
name; xyz is the password). Recall that when the code is initially executed,
the ActiveWorkbook is the user file, not the master. Getting closer!

Workbooks.Open Filename:=MasterFile
ActiveWorkbook.Unprotect (xyz)
 

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