jueves, agosto 28, 2014

Comprobar si existe un archivo en VBA

Función para comprobar si existe o no un archivo. Como parámetro de entrada tengo la ruta del archivo y la función devuelve si existe o no.

Function fileExists(filename) As Boolean
   Dim fso, msg
   Set fso = CreateObject("Scripting.FileSystemObject")
   If (fso.fileExists(filename)) Then
      fileExists = True
      Exit Function
   Else
      fileExists = False
      Exit Function
   End If
End Function

No hay comentarios: