From: Lakefront on
hello group:
i am using the following C# statement to acquire the Excel instance
currently running:

Excel.Application app =
(Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
--

but, the value of app is System.__ComObject.
why isn't it Excel.Workbook or Excel.Application?

note, i have Excel running and a workbook is opened.

thanks in advance...
LakeFront.
From: Jeroen Mostert on
Lakefront wrote:
> hello group:
> i am using the following C# statement to acquire the Excel instance
> currently running:
>
> Excel.Application app =
> (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
>
> --
>
> but, the value of app is System.__ComObject.
> why isn't it Excel.Workbook or Excel.Application?
>
Because you're actually getting a COM wrapper rather than an instance of any
particular class.

Use interfaces rather than classes: casting to IApplication should work.

--
J.
http://symbolsprose.blogspot.com
From: Lakefront on
problem solved!



Lakefront wrote:
> hello group:
> i am using the following C# statement to acquire the Excel instance
> currently running:
>
> Excel.Application app =
> (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
>
> --
>
> but, the value of app is System.__ComObject.
> why isn't it Excel.Workbook or Excel.Application?
>
> note, i have Excel running and a workbook is opened.
>
> thanks in advance...
> LakeFront.