Monday, December 3, 2018

vba - Assigning password to multiple workbooks in a given folder



Let me tell you the issue. We prepare summary report, based on a report I can split files in separate workbooks.




The main problem is:



I tried many ways to protect Multiple workbooks with a different password. In my excel password file have all list of excel names in column A and list of a different password in column B ( minimum 100 excel files and it may reach 500 files maximum) according to excel column A name need to assign password column B in folder workbook. It's really painful to do for every month manually



Is there an easy way to protect multiple workbooks without opening each one and assigning password through VBA codes? As per my knowledge, we can assign the same password to all workbook, but am looking different password according to my excel stored password as required



Really appreciate your help


Answer



a possible solution




Sub protectwpwd()
Dim i As Long, wb As Workbook, ws As Worksheet
i = 1
Set wb = ThisWorkbook
Set ws = wb.ActiveSheet
While ws.Cells(i, 1) <> ""
Workbooks.Open ws.Cells(i, 1)
ActiveWorkbook.Saveas ws.cells(i,1),Password:=ws.Cells(i, 2)
ActiveWorkbook.Close

i = i + 1
Wend
End Sub

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...