Documents.Count returns 0 with documents still open
Dearest helpers,
I made a script in my normal.dotm file that should loop through all opened docs, executes some code on each, closes it and when the last one is closed it quits the grey window that's left over.
In code :
Code:
Do while Word.Application.Documents.Count <> 0
Documents(1).Activate
Call mycode()
Active Document.close()
Loop
Application.quit
It does do this, but it leaves documents open. I Guess I'm running multiple instances. How to actually loop all open documents?
Cor
VBA - count all open documents from multiple instances / processes
Hi,
I've honestly been looking for an answer for months. Help is appreciated.
When I select 3 Word files and hit [enter], they are opened in 3 separate processes. How to count them all?
The following code doesn't work because it always returns 1 as each instance/process contains 1 of the documents.
Code:
Word.Application.Documents.Count
Actually I want to run a function on every opened document (like SaveAs PDF) and close them afterwards, one by one. Maybe I need to loop through every Word.Application?
Is that possible?
Cor