Test it:
Option Explicit
Sub EnumWordRunningFiles()
Dim WrdApp As Object, file As Object
On Error GoTo Err_EnumWordRunningFiles
Set WrdApp = GetObject(, "Word.Application")
For Each file In WrdApp.Documents
MsgBox file.FullName, vbInformation, "Message"
Next
Exit_EnumWordRunningFiles:
Set WrdApp = Nothing
Exit Sub
Err_EnumWordRunningFiles:
MsgBox Err.Description, vbExclamation, "Error No. " & Err.Number
Resume Exit_EnumWordRunningFiles
End Sub
Sub EnumExcelRunningFiles()
Dim ExcApp As Object, file As Object
On Error GoTo Err_EnumExcelRunningFiles
Set ExcApp = GetObject(, "Excel.Application")
For Each file In ExcApp.Workbooks
MsgBox file.Name, vbInformation, "Message"
Next
Exit_EnumExcelRunningFiles:
Set ExcApp = Nothing
Exit Sub
Err_EnumExcelRunningFiles:
MsgBox Err.Description, vbExclamation, "Error No. " & Err.Number
Resume Exit_EnumExcelRunningFiles
End Sub