Run a shared macro using automation

S

Siddharthad

Hello,

I am trying to run a shared macro (in office11\xlstart\personal.xls) from
ASP .net application.

In my function I am using the following code to execute the macro, but it is
unable to locate the macro and erroring out.

private void a()
{
RunMacro(objApp, new Object[]{@"C:\Program Files\Microsoft
Office\OFFICE11\XLSTART\personal.xls!FormatGrid"});
}


private void RunMacro(object oApp, object[] oRunArgs)
{
oApp.GetType().InvokeMember("Run",
System.Reflection.BindingFlags.Default
|System.Reflection.BindingFlags.InvokeMethod,
null, oApp, oRunArgs);
}

The code errors out with the following inner exception.

The macro 'C:\Program Files\Microsoft
Office\OFFICE11\XLSTART\personal.xls!FormatGrid' cannot be found.

If I take out the fully qualifying path and run with only formatGrid, it
still cannot recognize the macro.

Can anybody help?

Thanks in advance!
Sidd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top