Sub GetValues()
Dim strPath As String
Dim OtherWb As Workbook
Dim EachFile As String
Application.ScreenUpdating = False
strPath = Application.GetOpenFilename(fileFilter:="Pick any xls file (*.xls, *.xls")
If strPath = "" Then Exit Sub
strPath = Left(strPath, InStrRev(strPath, "\") - 1)
EachFile = Dir(strPath & "\*.xls")
Do While EachFile <> "" ' Start the loop.
MsgBox strPath & "\" & EachFile
If EachFile = ThisWorkbook.Name Then GoTo nxt
Set OtherWb = Workbooks.Open(EachFile, False)
Application.DisplayAlerts = False
OtherWb.SaveAs strPath & "\" & EachFile, Password:="password"
Application.DisplayAlerts = True
OtherWb.Close False
nxt:
EachFile = Dir ' Get next xls file
Loop
Application.ScreenUpdating = True
Set OtherWb = Nothing
End Sub
|