Click here to Skip to main content
12,406,687 members (57,132 online)
Rate this:
 
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 0:28am
Updated 19-Apr-12 0: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 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. :)
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160730.1 | Last Updated 10 Apr 2013
Copyright © CodeProject, 1999-2016
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