comObject可以转换为Excel.ApplicationClass?

我在用着

(Excel.Application)Marshal.GetActiveObject("Excel.Application") 

它返回一个_ComObjecttypes,但我想知道如何能够将其转换为Excel.ApplicationClass ,我将如何去做呢?

这篇知识库文章定义了以下内容。

 //Excel Application Object Excel.Application oExcelApp; this.Activate(); //Get reference to Excel.Application from the ROT. oExcelApp = (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application"); //Display the name of the object. MessageBox.Show(oExcelApp.ActiveWorkbook.Name); //Release the reference. oExcelApp = null;