Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Incorrect UDF call

Hi All,

Ive created com automation add-in for Excel 2007 in Visual Studio 2008(I
use com automation add-in because Ive to create UDFs)

All works fine, but udf function is called before user is pressed Ok in
Function Arguments window, i.e. the function is called when all function
arguments are entered. How I can change this, i.e. the function should be
called ONCE and ONLY after Ok button is pressed.

Here is the code


[ComVisible(true)]
public interface IUDFs

{

void Test(object value1, object value2);

}



[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[Guid("6D3442CB-5DCB-44d1-8AFD-2693A8ACF465")]
[ProgId("AutomationAddin.UDFs")]
public class UDFs : IUDFs
{
public UDFs()
{

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

}

#region Implementation of IUDFs

public void Test(object value1, object value2)
{
if (value1 is Missing || value2 is Missing)
return;
//Do Work
}

#endregion

#region Register UnRegister Add-in

[ComRegisterFunction]
public static void RegisterFunction(Type type)
{

Registry.ClassesRoot.CreateSubKey(GetSubKeyName(ty pe,
"Programmable"));

RegistryKey key =
Registry.ClassesRoot.OpenSubKey(GetSubKeyName(type , "InprocServer32"), true);

key.SetValue(string.Empty, Environment.SystemDirectory +
@"\mscoree.dll", RegistryValueKind.String);

}



[ComUnregisterFunction]
public static void UnregisterFunction(Type type)

{

Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(ty pe,
"Programmable"), false);

}



private static string GetSubKeyName(Type type, string subKeyName)
{

var subKey = new StringBuilder();
subKey.Append(@"CLSID\{");
subKey.Append(type.GUID.ToString().ToUpper());
subKey.Append(@"}\");
subKey.Append(subKeyName);
return subKey.ToString();

}
#endregion Register UnRegister Add-in

}

Thanks in advance for any help!

Thanks,
GSerjo

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Incorrect UDF call

See http://www.decisionmodels.com/calcsecretsj.htm#FuncWiz for a VBA
solution you may be able to adapt : I think this still works in Excel 2007.

Charles
___________________________________
The Excel Calculation Site
http://www.decisionmodels.com

"GSerjo" wrote in message
...
Hi All,

I've created com automation add-in for Excel 2007 in Visual Studio 2008(I
use com automation add-in because I've to create UDFs)

All works fine, but udf function is called before user is pressed Ok in
"Function Arguments" window, i.e. the function is called when all function
arguments are entered. How I can change this, i.e. the function should be
called ONCE and ONLY after "Ok" button is pressed.

Here is the code


[ComVisible(true)]
public interface IUDFs

{

void Test(object value1, object value2);

}



[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[Guid("6D3442CB-5DCB-44d1-8AFD-2693A8ACF465")]
[ProgId("AutomationAddin.UDFs")]
public class UDFs : IUDFs
{
public UDFs()
{

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

}

#region Implementation of IUDFs

public void Test(object value1, object value2)
{
if (value1 is Missing || value2 is Missing)
return;
//Do Work
}

#endregion

#region Register UnRegister Add-in

[ComRegisterFunction]
public static void RegisterFunction(Type type)
{

Registry.ClassesRoot.CreateSubKey(GetSubKeyName(ty pe,
"Programmable"));

RegistryKey key =
Registry.ClassesRoot.OpenSubKey(GetSubKeyName(type , "InprocServer32"),
true);

key.SetValue(string.Empty, Environment.SystemDirectory +
@"\mscoree.dll", RegistryValueKind.String);

}



[ComUnregisterFunction]
public static void UnregisterFunction(Type type)

{

Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(ty pe,
"Programmable"), false);

}



private static string GetSubKeyName(Type type, string subKeyName)
{

var subKey = new StringBuilder();
subKey.Append(@"CLSID\{");
subKey.Append(type.GUID.ToString().ToUpper());
subKey.Append(@"}\");
subKey.Append(subKeyName);
return subKey.ToString();

}
#endregion Register UnRegister Add-in

}

Thanks in advance for any help!

Thanks,
GSerjo




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Incorrect UDF call

Hi Charles,

Thanks a lot for the answer, but the article does not contain answer :(

"Charles Williams" wrote:

See http://www.decisionmodels.com/calcsecretsj.htm#FuncWiz for a VBA
solution you may be able to adapt : I think this still works in Excel 2007.

Charles
___________________________________
The Excel Calculation Site
http://www.decisionmodels.com

"GSerjo" wrote in message
...
Hi All,

I've created com automation add-in for Excel 2007 in Visual Studio 2008(I
use com automation add-in because I've to create UDFs)

All works fine, but udf function is called before user is pressed Ok in
"Function Arguments" window, i.e. the function is called when all function
arguments are entered. How I can change this, i.e. the function should be
called ONCE and ONLY after "Ok" button is pressed.

Here is the code


[ComVisible(true)]
public interface IUDFs

{

void Test(object value1, object value2);

}



[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[Guid("6D3442CB-5DCB-44d1-8AFD-2693A8ACF465")]
[ProgId("AutomationAddin.UDFs")]
public class UDFs : IUDFs
{
public UDFs()
{

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

}

#region Implementation of IUDFs

public void Test(object value1, object value2)
{
if (value1 is Missing || value2 is Missing)
return;
//Do Work
}

#endregion

#region Register UnRegister Add-in

[ComRegisterFunction]
public static void RegisterFunction(Type type)
{

Registry.ClassesRoot.CreateSubKey(GetSubKeyName(ty pe,
"Programmable"));

RegistryKey key =
Registry.ClassesRoot.OpenSubKey(GetSubKeyName(type , "InprocServer32"),
true);

key.SetValue(string.Empty, Environment.SystemDirectory +
@"\mscoree.dll", RegistryValueKind.String);

}



[ComUnregisterFunction]
public static void UnregisterFunction(Type type)

{

Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(ty pe,
"Programmable"), false);

}



private static string GetSubKeyName(Type type, string subKeyName)
{

var subKey = new StringBuilder();
subKey.Append(@"CLSID\{");
subKey.Append(type.GUID.ToString().ToUpper());
subKey.Append(@"}\");
subKey.Append(subKeyName);
return subKey.ToString();

}
#endregion Register UnRegister Add-in

}

Thanks in advance for any help!

Thanks,
GSerjo





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call Center Management: How to calculate 'cost per call' Denniso6 Excel Discussion (Misc queries) 2 June 25th 06 05:01 PM
time sum incorrect mtovbin Excel Worksheet Functions 7 June 1st 06 04:18 AM
Incorrect Am and Pm MrBlackForest Excel Discussion (Misc queries) 2 January 26th 06 03:11 AM
Incorrect Sum ashlandpmac Excel Discussion (Misc queries) 1 April 15th 05 01:25 AM
Incorrect Sum AshlandPmac Excel Discussion (Misc queries) 1 April 14th 05 10:41 PM


All times are GMT +1. The time now is 08:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"