How do I access Word documents in other WINWORD.EXE processes from inside a VBA macro? RRS feed

  • Question

  • I'm writing a VBA macro for Word 2003 that needs to look at ALL the open Word documents (specifically at their custom properties), including the Word documents that may be in other WINWORD.EXE processes. I've tried the following For loop: 

       Dim doc As Document
       For Each doc In Documents

    But that only cycles through the open documents that are within the same WINWORD.EXE process as the document containing my macro -- it doesn't give me access to the open documents in any other currently running WINWORD.EXE process(es). How can I get access to the open documents in those other WINWORD.EXE processes?

    Wednesday, December 14, 2011 6:04 AM


  • Hi hungry

    This isn't going to be possible using VBA, alone. I think it's going to require the Windows API in order to access all processes (think Windows Task Pane). And even then, I'm not sure you'd be able to work with the documents in those processes - that will depend on whether such a process can be assigned to a Word.Application object within VBA.

    I'm not familiar enough with the Windows API to be able to offer you any code samples in this direction.

    With the .NET framework I know it would be possible. As a "last resort" you could create a COM-Visible DLL in VB.NET or C# that can be called from your VBA code and do this for you.

    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bruce Song Monday, December 26, 2011 6:41 AM
    Wednesday, December 14, 2011 10:17 AM