parttime_guy
03-29-2010, 10:49 PM
I have this sub below.....
When I run this it runs on all files in the folder (including .zip files)
Can I run this sub only on ".xls" files
Sub Remove_password()
Dim wkb1 As Workbook
Dim wksMACRO As Worksheet
Dim fso, f, fs, f1
Dim FileExtStr As String
Dim Filter As String
'------Password's need to be entered in Sheet1
Set Pass1 = Sheet1.Range("B1")
Set Pass2 = Sheet1.Range("B2")
Application.DisplayAlerts = False
ThisWorkbook.Activate
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.getfolder(ThisWorkbook.path)
Set fs = f.Files
For Each f1 In fs
If ThisWorkbook.Name <> f1.Name Then
Set wkb1 = Application.Workbooks.Open(ThisWorkbook.path & "\" & f1.Name, , , , Pass1, True)
wkb1.Password = Pass2
wkb1.Save
wkb1.Close
End If
Next
MsgBox "Congratulations!!!" & vbCrLf & "All Files in the path have been updated successfully"
Application.DisplayAlerts = True
End Sub
Kindly help
Thx-n-BR
When I run this it runs on all files in the folder (including .zip files)
Can I run this sub only on ".xls" files
Sub Remove_password()
Dim wkb1 As Workbook
Dim wksMACRO As Worksheet
Dim fso, f, fs, f1
Dim FileExtStr As String
Dim Filter As String
'------Password's need to be entered in Sheet1
Set Pass1 = Sheet1.Range("B1")
Set Pass2 = Sheet1.Range("B2")
Application.DisplayAlerts = False
ThisWorkbook.Activate
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.getfolder(ThisWorkbook.path)
Set fs = f.Files
For Each f1 In fs
If ThisWorkbook.Name <> f1.Name Then
Set wkb1 = Application.Workbooks.Open(ThisWorkbook.path & "\" & f1.Name, , , , Pass1, True)
wkb1.Password = Pass2
wkb1.Save
wkb1.Close
End If
Next
MsgBox "Congratulations!!!" & vbCrLf & "All Files in the path have been updated successfully"
Application.DisplayAlerts = True
End Sub
Kindly help
Thx-n-BR