I need some help. I want to check if the folder contains xlsx file, if there is just one then the code should follow. If there is no xlsx file in the folder the macro should stop. For all different extension sotp as well. I have been blocked if the first file has different extension.
Code:
Sub checkIFfile()
Dim zxFolder As Object
Dim zxFile As Object
Dim zxFileSystemObject As Object
zxFolderName = "[URL="file://\\adwc\TEAMS\TOOL_ADMIN\04_Requests OS"]\\adwc\TEAMS\TOOL_ADMIN\04_Requests OS[/URL]"
Set zxFileSystemObject = CreateObject("Scripting.FileSystemObject")
Set zxFolder = zxFileSystemObject.GetFolder(zxFolderName)
For Each zxFile In zxFolder.Files
If zxFileSystemObject.GetExtensionName(zxFile.path) = "xlsx" Then
MsgBox "YES"
Else
MsgBox "NO"
End If
Next
End Sub
Last edited: