' --- Check if a file or directory is present, and return TRUE or
' FALSE to indicate the state.
Function FileDirExists(s_pathhandle As String) As Boolean
Dim dummy As Integer
On Error Resume Next
dummy = GetAttr(s_pathhandle)
Select Case Err.Number
Case Is = 0
FileDirExists = True
Case Else
FileDirExists = False
End Select
On Error GoTo 0
End Function
Word/VBA - How to check if a file or directory exists
This function can be used in a word macro to check if a certain file or directory is present on the file system.