Edit: Before I put a specific Excel file or its window to the front I need to check whether it's running/still open.
Old Question: I want to set a specific Excel window to the front.
With this VBScript code I can activate one single Excel window by its name. But since more than one Excel window are opened it doesn't work anymore. In this case it won't find the needed window and it can't be checked if it's open. So it will always say that the ExcelFileName is not open.
Set WshShell = WScript.CreateObject ("WScript.Shell")
if WshShell.AppActivate(ExcelFileName) = True then
wscript.echo ExcelFileName & " is opened."
WshShell.sendkeys "%x" 'in Excel 2003 this would had opened the extra-menu-droplist of the menu-bar. Now it just activates Excel.
else
wscript.echo ExcelFileName & " is not open."
End if
How can I make it work with more than one opened Excel window?