|
Prev: WCF - Minumim Data size for WCF Message
Next: How to determine the CAS for an assembly at runtime
From: Lakefront on 16 Jun 2008 14:29 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 16 Jun 2008 16:31 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 17 Jun 2008 17:05 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.
|
Pages: 1 Prev: WCF - Minumim Data size for WCF Message Next: How to determine the CAS for an assembly at runtime |