Click here to Skip to main content
11,487,406 members (70,095 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6 VB VBA
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 19-Apr-12 1:28am
Edited 19-Apr-12 1:37am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
micheal_jhones at 19-Apr-12 7:26am
   
this code shows windows title not current runing file
Slacker007 at 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. :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,063
1 OriginalGriff 8,287
2 Sascha Lefèvre 3,334
3 Maciej Los 2,946
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 10 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100