ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Password protected workbook (https://www.excelbanter.com/excel-programming/390641-password-protected-workbook.html)

JDaywalt

Password protected workbook
 
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?

Mike

Password protected workbook
 
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
"JDaywalt" wrote:

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?


JDaywalt

Password protected workbook
 
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?

"Mike" wrote:

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
"JDaywalt" wrote:

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?


Mike

Password protected workbook
 
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
"JDaywalt" wrote:

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?

"Mike" wrote:

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
"JDaywalt" wrote:

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?


Mike

Password protected workbook
 
Post more of your code for me

"JDaywalt" wrote:

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)



"Mike" wrote:

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
"JDaywalt" wrote:

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?

"Mike" wrote:

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
"JDaywalt" wrote:

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?



All times are GMT +1. The time now is 12:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com