Public Function comprobarCarpeta(carp As String) As Boolean ' Comprueba si el directorio elegido contiene imágenes
On Error GoTo ControlError
Dim oFSO As New Scripting.FileSystemObject
Dim oFile As Scripting.File
Dim oCarpeta As Scripting.Folder
Set oCarpeta = oFSO.GetFolder(carp)
For Each oFile In oCarpeta.Files
If Right(oFile.Name, 4) = ".bmp" Or Right(oFile.Name, 4) = ".jpg" Or Right(oFile.Name, 4) = ".gif" Or Right(oFile.Name, 4) = ".dib" Then
Set oFSO = Nothing
Set oCarpeta = Nothing
Set oFile = Nothing
comprobarCarpeta = True
Exit Function
End If
Next
ComprobarCarpeta = False
Exit Function
ControlError:
Set oCarpeta = Nothing
Set oFSO = Nothing
Set oFile = Nothing
ComprobarCarpeta = False
If Err.Number <> 5 Then
MsgBox "Error número: " & Err.Number & vbCrLf & Err.Description, vbCritical, "Comprobar carpeta"
End If
End Function