Suppose I type a code like this:
$excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
It will only work if I only have one Excel application open.  If I have two Excel applications open, $excel might reference to the wrong one.  Is there a way to reference to a specific Excel application, for example, based on its filename or its window title?
 
    