Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
Hi....

I wanna run a predefined excel macro from my .net application.
I am using the following code for doing this and it is throwing an TargetInvocationException-

Thread t = new Thread(delegate()
{

Excel.Application _excelApp = new Microsoft.Office.Interop.Excel.Application();  

Marshal.GetActiveObject("Excel.Application"); 
_excelApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default 
|
System.Reflection.BindingFlags.InvokeMethod, null, _excelApp, new 
object[] { "SetFont" }); 

});

t.IsBackground = true; 
t.Start();


Please tell me that why it is throwing an exception while this code is running perfectly for Word Application.

Thanks in advance for any help.

Naina.
Posted
Updated 5-Oct-10 21:18pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900