You are reading a single comment by @Chalfie and its replies. Click here to read the full conversation.
  • Sub RemovePasswordProtection()
    Dim folderPath As String
    Dim password As String
    Dim wb As Workbook
    Dim file As String
    
    ' Set the folder path where your Excel files are located
    folderPath = "filepathgoeshere"
    
    ' Set the password for the Excel files
    password = "pwd"
    
    ' Disable alerts to prevent prompts
    Application.DisplayAlerts = False
    
    ' Loop through each Excel file in the folder
    file = Dir(folderPath & "*.xlsx")
    
    Do While file <> ""
    ' Open the workbook with the specified password
    Set wb = Workbooks.Open(folderPath & file, password:=password)
    
    ' Save the workbook to remove password protection
    wb.Save
    wb.Close
    
    ' Get the next file in the folder
    file = Dir
    Loop
    
    ' Enable alerts again
    Application.DisplayAlerts = True
    
    ' Display a message
    MsgBox "Password protection removed from all Excel files in the folder.", vbInformation
    End Sub
    
  • Aren't you just saving the file again? I'd say you need to save as and remove the password (although I can't test this as my Excel is currently a white screen).

    Edit, looks like Password:="" is what you want

    ActiveWorkbook.SaveAs Filename:=myfilename, _
            FileFormat:=xlExcel12, CreateBackup:=False, Password:=""
    
About

Avatar for Chalfie @Chalfie started