エクセルのアドインをMSDNの
Excel 用のオートメーション アドインとしてマネージ コードを使用する
を参考に(といってもコピーなんですけどね・・・)ビルドして、エクセルの「ツール」-「アドイン」-「オートメーション」から以下の作成したアドインを読み込むと「アドイン 'mscoree.dll' が見つかりません。リストから削除しますか?」と怒られてしまいます。どうしたものかと・・・、以下の青くした部分のように変更してもダメなようだし。
using System;
using System.Runtime.InteropServices;
namespace TaxTables
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class TaxTables
{
public static double Tax(double income)
{
if (income > 0 && income <= 7000) { return (.10 * income); }
return 0;
}
[ComRegisterFunctionAttribute]
public static void RegisterFunction(System.Type t)
{
// Microsoft.Win32.Registry.ClassesRoot.CreateSubKey
// ("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Programmable");
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(
"CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Programmable");
key.SetValue("", Environment.GetFolderPath(Environment.SpecialFolder.System) + @"\mscoree.dll");
}
[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(System.Type t)
{
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey
("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Programmable");
}
}
}
環境:VS2005 Microsoft Excel 2003
う~ん。う~ん。