• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Protect all files in a folder and subfolder starting with word Performance

Excellenceisme

New Member
Hello

I saw this post online at Chandoo VBA forum where they have made macro to add password to all the files in a folder. I will post the macro here again. But I want to change password in the sub folders too and also another criteria is I want to change password of only those fille That starts with name "Performance Report". there are various file starting with same name but for different BU and month
For example : if a folder contains below files, I want to give password all the files that starts with word Performance Report no matter what BU or month they belong. I don't want to do anything to file " Ledger Transaction Report" that exist. Can someone please help me? I am not v good at VBA
Performance Report BU1- Nov
Performance Report BU2 - Nov
Performance Report BU1 - Oct
Ledger Transaction Report
 

Attachments

rollis13

Member
Hi to all.
Isn't this a case of Excel (or Chandoo) Circular Reference :confused:.
By the way Excellenceisme, your macro already processes subfolder.
For the second request add these two lines of code here:
Code:
'...
End With
For Each wb In folder.Files
    If Right(wb.Name, 3) = "xls" Or Right(wb.Name, 4) = "xlsx" Or Right(wb.Name, 4) = "xlsm" Then
        If Left(wb.Name, 18) <> "Performance Report" Then GoTo 25 '<- added
        On Error Resume Next
'...
and here:
Code:
'...
25  Next
    For Each subfolder In folder.SubFolders
        For Each wb In subfolder.Files
            If Right(wb.Name, 3) = "xls" Or Right(wb.Name, 4) = "xlsx" Or Right(wb.Name, 4) = "xlsm" Then
                If Left(wb.Name, 18) <> "Performance Report" Then GoTo 50 '<- added
                On Error Resume Next
'...
 
Last edited:
Top