khalid79m
11-28-2008, 08:31 AM
:dunno
Private Sub SITE()
Application.EnableEvents = False
Dim i As Integer, wb As Workbook
With Application.FileSearch
.NewSearch
.LookIn = "\\Uk3\traner\jj\UK\Edirgh\ (file://\\Uk3\traner\jj\UK\Edinburgh\)"
.SearchSubFolders = True
.Filename = "*.xls"
.Application.DisplayAlerts = False
.Execute
For i = 1 To .FoundFiles.Count
ActiveWorkbook.Name
Set wb = Workbooks.Open(Filename:=.FoundFiles(i), ReadOnly:=False)
Sheets("CallData").Select
ActiveSheet.Unprotect Password:="54YY4F"
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
Range("B1").FormulaR1C1 = "12/3/2008 12:00"
wb.Close savechanges:=True
Next i
End With
Application.EnableEvents = True
End Sub
I have the above script, I need it only run if the workbook is not in readonly and save the file , if it is readonly then simply close the file without save...
Private Sub SITE()
Application.EnableEvents = False
Dim i As Integer, wb As Workbook
With Application.FileSearch
.NewSearch
.LookIn = "\\Uk3\traner\jj\UK\Edirgh\ (file://\\Uk3\traner\jj\UK\Edinburgh\)"
.SearchSubFolders = True
.Filename = "*.xls"
.Application.DisplayAlerts = False
.Execute
For i = 1 To .FoundFiles.Count
ActiveWorkbook.Name
Set wb = Workbooks.Open(Filename:=.FoundFiles(i), ReadOnly:=False)
Sheets("CallData").Select
ActiveSheet.Unprotect Password:="54YY4F"
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
Range("B1").FormulaR1C1 = "12/3/2008 12:00"
wb.Close savechanges:=True
Next i
End With
Application.EnableEvents = True
End Sub
I have the above script, I need it only run if the workbook is not in readonly and save the file , if it is readonly then simply close the file without save...