View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robin Robin is offline
external usenet poster
 
Posts: 2
Default RegisteredFunctions in C# fails when trying to get the list of addins and function

Hello
I am using a small C# program which uses the office interop and tries
to get the list of addin in a worksheet, but it always returns a
System.DBNull but if I write a small VBA procedure it always succeeds
any ideas or thoughts, I have attach a the code been executed in C#.

using System;
using Microsoft.Office.Core;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Windows.Forms;

namespace ExcelRangeRunMacro
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
RunTest();
Console.ReadLine();
}

private static void RunTest()
{
Excel._Application xlApplication = null;
Excel._Workbook workbook = null;

//Start Excel and get Application object.
xlApplication = (Excel.Application) new Excel.Application();
xlApplication.Visible = true;
workbook =
(Excel._Workbook)(xlApplication.Workbooks.Open(@"H :\Personal\abc_mod.xls", Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing));

xlApplication.Visible = true;
xlApplication.UserControl = true;

object olist2 = xlApplication.get_RegisteredFunctions(Type.Missing ,
Type.Missing);
}
}
}