S
Steph
Hi Tom or Bob,
I added the If LCase(Filename) <> LCase(ThisWorkbook.Filename) Then
line of code like you suggested, but got an error Method or Data member not
found. So I then tried top replace Filename with Fullname. It did not
error, but gave the same results as when I did not have the line of code in.
Did I put the line in the wrong place? The sub and function are below.
Thanks!
Sub ProcessFiles()
Dim FSO As Object
Dim fldr As Object
Dim sFolder As String
Dim Folder As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
sFolder = "S:\Global_Share\Operations\Kineticom Timesheet\Approvals\" &
Range("R5").Value
If sFolder <> "" Then
Set Folder = FSO.GetFolder(sFolder)
If FileCountOK(Folder) Then
CDO_Email_GM
End If
End If ' sFolder <> ""
End Sub
Function FileCountOK(pzFolder As Object)
Dim i As Long
Dim file As Object
Dim Files As Object
FileCountOK = True
Set Files = pzFolder.Files
For Each file In Files
If LCase(Filename) <> LCase(ThisWorkbook.Filename) Then
If file.Type = "Microsoft Excel Worksheet" Then
i = i + 1
Workbooks.Open Filename:=file.path
With ActiveWorkbook
FileCountOK = .ActiveSheet.Range("A2").Value = 1
.Close savechanges:=False
If Not FileCountOK Then Exit Function
End With
End If
End If
Next file
End Function
I added the If LCase(Filename) <> LCase(ThisWorkbook.Filename) Then
line of code like you suggested, but got an error Method or Data member not
found. So I then tried top replace Filename with Fullname. It did not
error, but gave the same results as when I did not have the line of code in.
Did I put the line in the wrong place? The sub and function are below.
Thanks!
Sub ProcessFiles()
Dim FSO As Object
Dim fldr As Object
Dim sFolder As String
Dim Folder As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
sFolder = "S:\Global_Share\Operations\Kineticom Timesheet\Approvals\" &
Range("R5").Value
If sFolder <> "" Then
Set Folder = FSO.GetFolder(sFolder)
If FileCountOK(Folder) Then
CDO_Email_GM
End If
End If ' sFolder <> ""
End Sub
Function FileCountOK(pzFolder As Object)
Dim i As Long
Dim file As Object
Dim Files As Object
FileCountOK = True
Set Files = pzFolder.Files
For Each file In Files
If LCase(Filename) <> LCase(ThisWorkbook.Filename) Then
If file.Type = "Microsoft Excel Worksheet" Then
i = i + 1
Workbooks.Open Filename:=file.path
With ActiveWorkbook
FileCountOK = .ActiveSheet.Range("A2").Value = 1
.Close savechanges:=False
If Not FileCountOK Then Exit Function
End With
End If
End If
Next file
End Function