Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is there a way to find the currently open file from Excel or Word process etc? , i want to get all the list of running processes in windows and which files they currently have open.

Thanks in advance!
Posted
Updated 19-Apr-12 0:37am
v2

Test it:
VB
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
 
Share this answer
 
http://www.mattsbits.co.uk/item-150.html[^]

I copied part of your question and searched Google. This is the first hit I found.

-- good luck.
 
Share this answer
 
Comments
micheal_jhones 19-Apr-12 7:26am    
this code shows windows title not current runing file
Slacker007 19-Apr-12 7:55am    
I guess what I was hinting at was to do a thorough search on Google first and do some personal research and/or leg work. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900