title: Use WMI query in VBA to get list of open files on local computer
body: <p>As per title.  Using <a href="https://blogs.technet.microsoft.com/heyscriptingguy/2005/02/16/how-can-i-list-open-sessions-and-open-files-on-a-computer/" rel="nofollow noreferrer">this code example</a> (3rd example down) as my starting point.  </p>
  
  <p>Here's my effort at VBA code, but it stalls at the first hurdle ("Run time error 438: object doesn't support this property or method")</p>
  
  <pre><code>Sub Test()
  
      Set objConnection = GetObject("WinNT://HM10")
  
      Set colResources = objConnection.Resources
  
      For Each objResource In colResources
  
          Debug.Print objResource.Path
  
      Next
  
  End Sub
  </code></pre>
  
  <p>HM10 is my computer name. Eventually it will need to be an environmental variable (if that's the right term) for whatever machine it happens to be on.</p>
  
  <p>EDIT:  Ok, more searching has led me to this:</p>
  
  <pre><code>Sub test()
  
     Filename = "."
  
     Set wmi = GetObject("winmgmts://./root/cimv2")
  
     qry = "SELECT * FROM Win32_Process WHERE CommandLine LIKE '%" &amp; Filename &amp; "%'"
  
     For Each p In wmi.ExecQuery(qry)
       Debug.Print p.commandline
     Next
  
  End Sub
  </code></pre>
  
  <p>which is closer,  but only shows local files, not network files.  I only need network files, how do I get them?</p>