0

With 3 Word documents opened in separate instances the Documents count will return 1 instead of 3.

Word.Application.Documents.Count

Is it possible to loop through all instances and count/address the documents?

Cor

Cor
  • 1
  • 1
  • Why do you have multiple Word application instances? How are the 3 word documents being opened into 3 separate instances? – Raymond Wu Oct 23 '21 at 08:55
  • For multiple instances you will likely need to look into Windows API calls to find each instance and check whatever from there. [Windows API Index](https://learn.microsoft.com/en-us/windows/win32/apiindex/windows-api-list) – Samuel Everson Oct 23 '21 at 09:08
  • https://stackoverflow.com/questions/30363748/having-multiple-excel-instances-launched-how-can-i-get-the-application-object-f has what you need for this – Tim Williams Oct 24 '21 at 05:12
  • Thx! I'm going to try to apply that to Word. @Raymond: that's the default behaviour when you select multiple files and press enter. If you open any document after that it will be added to the last opened instance. A big problem with many other forum topics is that the files aren't opened by the VBA script itself but earlier by a user, so I can't list the instance objects in advance. I guess this will work though – Cor Oct 24 '21 at 09:16
  • Hi all, the given links and the topic this is duplicated to did give the correct answer. I did find it difficult to interpret with the VBA knowledge I had back then, but the following answer made it clear to me how to build up the code: https://stackoverflow.com/questions/54374826/how-to-iterate-over-multiple-word-instances-with-accessibleobjectfromwindow – Cor Jan 07 '23 at 05:08

0 Answers0