<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Registering a User Defined Function with Excel</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Thu, 09 Feb 2012 18:06:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Toledano</title>
		<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/#comment-57333</link>
		<dc:creator>Toledano</dc:creator>
		<pubDate>Tue, 18 Jan 2011 20:04:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1350#comment-57333</guid>
		<description>&lt;p&gt;I&#039;ve built a XLA/XLSM solution working perfectly with more 20 UDF including arguments and help file.&lt;/p&gt;
&lt;p&gt;I want to transfer that on C# Visual Studio 8 Express Edition without DNA (pure Microsoft C#).&lt;/p&gt;
&lt;p&gt;This work perfectly with registering each UDF, but I dont know how to register with arguments and help !&lt;/p&gt;
&lt;p&gt;The code used and published in various site and blogs is :&lt;/p&gt;
&lt;p&gt;===============================================================&lt;br&gt;
        [ComRegisterFunctionAttribute]&lt;br&gt;
        public static void RegisterFunction(Type type)&lt;br&gt;
        {&lt;/p&gt;
&lt;p&gt;            Registry.ClassesRoot.CreateSubKey(&lt;/p&gt;
&lt;p&gt;              GetSubKeyName(type, &quot;Programmable&quot;));&lt;/p&gt;
&lt;p&gt;            RegistryKey key = Registry.ClassesRoot.OpenSubKey(&lt;/p&gt;
&lt;p&gt;              GetSubKeyName(type, &quot;InprocServer32?), true);&lt;/p&gt;
&lt;p&gt;            key.SetValue(&quot;&quot;,&lt;/p&gt;
&lt;p&gt;              System.Environment.SystemDirectory + @&quot;mscoree.dll&quot;,&lt;/p&gt;
&lt;p&gt;              RegistryValueKind.String);&lt;br&gt;
        }&lt;/p&gt;
&lt;p&gt;        [ComUnregisterFunctionAttribute]&lt;br&gt;
        public static void UnregisterFunction(Type type)&lt;br&gt;
        {&lt;/p&gt;
&lt;p&gt;            Registry.ClassesRoot.DeleteSubKey(&lt;/p&gt;
&lt;p&gt;              GetSubKeyName(type, &quot;Programmable&quot;), false);&lt;br&gt;
        }&lt;/p&gt;
&lt;p&gt;=======================================================================&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;ve built a XLA/XLSM solution working perfectly with more 20 UDF including arguments and help file.</p>
<p>I want to transfer that on C# Visual Studio 8 Express Edition without DNA (pure Microsoft C#).</p>
<p>This work perfectly with registering each UDF, but I dont know how to register with arguments and help !</p>
<p>The code used and published in various site and blogs is :</p>
<p>===============================================================<br />
        [ComRegisterFunctionAttribute]<br />
        public static void RegisterFunction(Type type)<br />
        {</p>
<p>            Registry.ClassesRoot.CreateSubKey(</p>
<p>              GetSubKeyName(type, &#8220;Programmable&#8221;));</p>
<p>            RegistryKey key = Registry.ClassesRoot.OpenSubKey(</p>
<p>              GetSubKeyName(type, &#8220;InprocServer32?), true);</p>
<p>            key.SetValue(&#8220;&#8221;,</p>
<p>              System.Environment.SystemDirectory + @&#8221;mscoree.dll&#8221;,</p>
<p>              RegistryValueKind.String);<br />
        }</p>
<p>        [ComUnregisterFunctionAttribute]<br />
        public static void UnregisterFunction(Type type)<br />
        {</p>
<p>            Registry.ClassesRoot.DeleteSubKey(</p>
<p>              GetSubKeyName(type, &#8220;Programmable&#8221;), false);<br />
        }</p>
<p>=======================================================================</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geoffrey</title>
		<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/#comment-40955</link>
		<dc:creator>Geoffrey</dc:creator>
		<pubDate>Sat, 12 Sep 2009 03:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1350#comment-40955</guid>
		<description>&lt;p&gt;toKeepItCool: show us the trick getting around with Evaulate 255 char limits as well.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>toKeepItCool: show us the trick getting around with Evaulate 255 char limits as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tuy</title>
		<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/#comment-29861</link>
		<dc:creator>tuy</dc:creator>
		<pubDate>Sat, 12 Jan 2008 06:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1350#comment-29861</guid>
		<description>&lt;p&gt;to KeepItCool: I still couldn&#039;t figure the trick getting around with Evaluate method, and still stuck with 255 characters.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>to KeepItCool: I still couldn&#8217;t figure the trick getting around with Evaluate method, and still stuck with 255 characters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Starbuck</title>
		<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/#comment-28700</link>
		<dc:creator>Starbuck</dc:creator>
		<pubDate>Wed, 14 Nov 2007 21:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1350#comment-28700</guid>
		<description>&lt;p&gt;Is there any new wisdom on this topic?  I&#039;ve created an automation addin with C# and it would be nice to see a category other than my namespace.class, and to see real help info.&lt;/p&gt;
&lt;p&gt;Has anyone translated Jurgen&#039;s VBA into a .NET class?  I&#039;ll try to translate if required but it would be nice to avoid effort duplication.  I&#039;ve been to Laurent&#039;s site but his offering doesn&#039;t seem to support automation either.&lt;/p&gt;
&lt;p&gt;Does Excel 2007, maybe with VSTO, recognize development in this area as a little more than a second-class citizen?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Is there any new wisdom on this topic?  I&#8217;ve created an automation addin with C# and it would be nice to see a category other than my namespace.class, and to see real help info.</p>
<p>Has anyone translated Jurgen&#8217;s VBA into a .NET class?  I&#8217;ll try to translate if required but it would be nice to avoid effort duplication.  I&#8217;ve been to Laurent&#8217;s site but his offering doesn&#8217;t seem to support automation either.</p>
<p>Does Excel 2007, maybe with VSTO, recognize development in this area as a little more than a second-class citizen?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frans</title>
		<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/#comment-19137</link>
		<dc:creator>Frans</dc:creator>
		<pubDate>Sun, 12 Mar 2006 11:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1350#comment-19137</guid>
		<description>&lt;p&gt;Further on my remark above: I realised that the Excel4 routine is based on the registration of a DLL function. Therefore you need a different DLL function for each UDF (arg2 in the code of KeepITcool above).&lt;/p&gt;
&lt;p&gt;If you want to register a number of UDF functions this is a bit tedious. So I created a text file  with all functions in user32.dll. I have replaced &quot;CharNextA&quot; in:&lt;/p&gt;
&lt;p&gt;SetGlobalName &quot;arg2?, &quot;CharNextA&quot; &lt;/p&gt;
&lt;p&gt;with a function that returns the last non-used DLL function from the text file.&lt;/p&gt;
&lt;p&gt;The only non-standard VBA in my addition to the code is the use of the &quot;hidden Excel namespace&quot;. I keep a counter in that namespace using SET.NAME and GET.NAME. The counter is up to date for the complete Excel session, but is reset to zero when Excel is closed. Just as the Doctor ordered.&lt;/p&gt;
&lt;p&gt;Everything works fine now. Still, I worry a bit about programming practice: we are using an obsolete fuction, that does our job becasue it contains a bug(correct me if I am wrong). What about new future versions of Excel?&lt;/p&gt;
&lt;p&gt;Please mail at &lt;a href=&quot;mailto:franswes@xs4all.nl&quot;&gt;franswes@xs4all.nl&lt;/a&gt; if you want a copy of the text file with the DLL functions, and the VBA code I have completed for this purpose.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Further on my remark above: I realised that the Excel4 routine is based on the registration of a DLL function. Therefore you need a different DLL function for each UDF (arg2 in the code of KeepITcool above).</p>
<p>If you want to register a number of UDF functions this is a bit tedious. So I created a text file  with all functions in user32.dll. I have replaced &#8220;CharNextA&#8221; in:</p>
<p>SetGlobalName &#8220;arg2?, &#8220;CharNextA&#8221; </p>
<p>with a function that returns the last non-used DLL function from the text file.</p>
<p>The only non-standard VBA in my addition to the code is the use of the &#8220;hidden Excel namespace&#8221;. I keep a counter in that namespace using SET.NAME and GET.NAME. The counter is up to date for the complete Excel session, but is reset to zero when Excel is closed. Just as the Doctor ordered.</p>
<p>Everything works fine now. Still, I worry a bit about programming practice: we are using an obsolete fuction, that does our job becasue it contains a bug(correct me if I am wrong). What about new future versions of Excel?</p>
<p>Please mail at <a href="mailto:franswes@xs4all.nl">franswes@xs4all.nl</a> if you want a copy of the text file with the DLL functions, and the VBA code I have completed for this purpose.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frans</title>
		<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/#comment-19135</link>
		<dc:creator>Frans</dc:creator>
		<pubDate>Sat, 11 Mar 2006 08:23:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1350#comment-19135</guid>
		<description>&lt;p&gt;In my case, this code works fine for one function. However, when I enter 2 functions in the same category, they both get the same number of parameters, and the same function and parameter descriptions.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>In my case, this code works fine for one function. However, when I enter 2 functions in the same category, they both get the same number of parameters, and the same function and parameter descriptions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/#comment-18961</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Wed, 22 Feb 2006 14:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1350#comment-18961</guid>
		<description>&lt;p&gt;be sure to replace  &quot;starting and ending double quotes&quot; and &#039;opening apostrophe&lt;br&gt;
with their ascii brethren&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>be sure to replace  &#8220;starting and ending double quotes&#8221; and &#8216;opening apostrophe<br />
with their ascii brethren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/#comment-18960</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Wed, 22 Feb 2006 14:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1350#comment-18960</guid>
		<description>&lt;p&gt;I&#039;ve contacted Jan Karel Pieterse, and we&#039;re working on fitting this into a class module&lt;br&gt;
which will be published on his site later.&lt;/p&gt;
&lt;p&gt;This method appears to be stable. No crashes on unregistering, or closing the workbook without unregistering. Can be called from an addin or without activeworkbook. Descriptions DO remain in the Function Wizard when the book is closed, similar to starting and unloading ATP addin.&lt;/p&gt;
&lt;p&gt;Using Application.MacroOptions requires an activeworkbook and stores the description and category number in 2 hidden lines in the VBA module.(the category NAME is stored in the workbook itself) This hardcoding may conflict with other addins using the same numbers. This approach does not.&lt;/p&gt;
&lt;p&gt;My &quot;trick&quot; used to circumvent the 255 character limit is all based on storing the argument values in Excel&#039;s &quot;Global namespace&quot;. (Laurent Longre uses the term &quot;Hidden Namespace&quot;). These names exist at application level and can be reached by all workbooks and addins using SET.NAME and GET.NAME macro functions&lt;/p&gt;
&lt;p&gt;Note the &quot;trick&quot; also works very well with the Evaluate method, which has a similar 255 char limit..&lt;/p&gt;
&lt;p&gt;here comes the code... hopefully ungarbled when HTML is done with it.&lt;/p&gt;
&lt;p&gt;Jurgen&lt;/p&gt;
&lt;p&gt;Option Explicit&lt;/p&gt;
&lt;p&gt;&#039;This is the function we want to &#039;describe&#039; in the Function Wizard&lt;br&gt;
&#039;Note the function is Private to avoid appearance in &#039;User Defined&#039; category&lt;br&gt;
Private Function Occurs(sText$, sPhrase$)&lt;br&gt;
With Application&lt;br&gt;
  Occurs = (Len(sText) - Len(.Substitute(sText, sPhrase, _&lt;br&gt;
      &quot;&quot;))) / .Max(1, Len(sPhrase))&lt;br&gt;
End With&lt;br&gt;
End Function&lt;/p&gt;
&lt;p&gt;&#039;This is the sample procedure to enter the function and argument&lt;br&gt;
&#039;descriptions for use in the Function Wizard&lt;br&gt;
Sub DescribeIT()&lt;br&gt;
&#039;keepITcool 2006-02-22&lt;/p&gt;
&lt;p&gt;&#039;Notes:&lt;br&gt;
&#039;Argument 1 must be a Dll name (as used in API declarations)&lt;br&gt;
&#039;Argument 2 must be a unique procedure with the dll&lt;br&gt;
&#039;Argument 3 should not be changed&lt;br&gt;
&#039;Argument 6 should not be changed&lt;/p&gt;
&lt;p&gt;&#039;For documentation on REGISTER()&lt;br&gt;
&#039;see macrofun.hlp and/or excel97sdk.chm&lt;/p&gt;
&lt;p&gt;&#039;Store the arguments in Excel&#039;s name space using SET.NAME&lt;br&gt;
&#039;------------------------------------&lt;br&gt;
SetGlobalName &quot;arg1?, &quot;user32.dll&quot;       &#039;module_text&lt;br&gt;
SetGlobalName &quot;arg2?, &quot;CharNextA&quot;        &#039;procedure&lt;br&gt;
SetGlobalName &quot;arg3?, &quot;P&quot;                &#039;type_text&lt;br&gt;
SetGlobalName &quot;arg4?, &quot;Occurs&quot;           &#039;function_text&lt;br&gt;
SetGlobalName &quot;arg5?, &quot;Text,Phrase&quot;      &#039;argument_text&lt;br&gt;
SetGlobalName &quot;arg6?, 1                  &#039;macro_type&lt;br&gt;
SetGlobalName &quot;arg7?, &quot;Cool Functions&quot;   &#039;category&lt;br&gt;
SetGlobalName &quot;arg8?, &quot;&quot;                 &#039;shortcut_text&lt;br&gt;
SetGlobalName &quot;arg9?, &quot;&quot;                 &#039;help_topic&lt;br&gt;
&#039;Function and Argument descriptions&lt;br&gt;
SetGlobalName &quot;arg10?, &quot;returns the number of times &quot; &amp; _&lt;br&gt;
    &quot;a phrase occurs in a text.&quot;&lt;br&gt;
SetGlobalName &quot;arg11?, &quot;is a (cell reference to) &quot; &amp; _&lt;br&gt;
    &quot;the text to be searched&quot;&lt;br&gt;
SetGlobalName &quot;arg12?, &quot;is a (cell reference to) &quot; &amp; _&lt;br&gt;
    &quot;the phrase to search for.&quot;&lt;/p&gt;
&lt;p&gt;&#039;Now Register your function&lt;br&gt;
&#039;----------------&lt;br&gt;
Application.ExecuteExcel4Macro _&lt;br&gt;
    &quot;REGISTER(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)&quot;&lt;br&gt;
&#039;Block access to the function pointer (could possibly be CALLed in xl97)&lt;br&gt;
Application.ExecuteExcel4Macro &quot;SET.NAME(arg4,0)&quot;&lt;/p&gt;
&lt;p&gt;&#039;Now remove the argument names&lt;br&gt;
&#039;------------------&lt;br&gt;
Dim i%&lt;br&gt;
For i = 1 To 12&lt;br&gt;
  SetGlobalName (&quot;arg&quot; &amp; i)&lt;br&gt;
Next&lt;br&gt;
End Sub&lt;/p&gt;
&lt;p&gt;Sub UnDescribeIT()&lt;br&gt;
Application.ExecuteExcel4Macro _&lt;br&gt;
    &quot;UNREGISTER(REGISTER.ID(&quot;&quot;user32?&quot;,&quot;&quot;CharNextA&quot;&quot;))&quot;&lt;br&gt;
End Sub&lt;/p&gt;
&lt;p&gt;Function SetGlobalName(sName As String, Optional ByVal vValue)&lt;br&gt;
&#039;Wrapper function for the SET.NAME xlm command&lt;br&gt;
&#039;If called without the optional vValue the name is DELETED.&lt;br&gt;
Dim sCmd$&lt;br&gt;
Select Case True&lt;br&gt;
  Case IsMissing(vValue)&lt;br&gt;
    sCmd = &quot;SET.NAME(&quot;&quot;&quot; &amp; sName &amp; &quot;&quot;&quot;)&quot;&lt;br&gt;
  Case TypeName(vValue) = &quot;String&quot; Or IsEmpty(vValue)&lt;br&gt;
    sCmd = &quot;SET.NAME(&quot;&quot;&quot; &amp; sName &amp; &quot;&quot;&quot;,&quot;&quot;&quot; &amp; vValue &amp; &quot;&quot;&quot;)&quot;&lt;br&gt;
  Case IsArray(vValue)&lt;br&gt;
    &#039;Arrays s/b passed as a string like &#039;{1,2,3}&#039;&lt;br&gt;
    SetGlobalName = CVErr(xlErrValue)&lt;br&gt;
    Exit Function&lt;br&gt;
  Case Else&lt;br&gt;
    With Application&lt;br&gt;
      vValue = .Substitute(CStr(vValue), .DecimalSeparator, &quot;.&quot;)&lt;br&gt;
    End With&lt;br&gt;
    sCmd = &quot;SET.NAME(&quot;&quot;&quot; &amp; sName &amp; &quot;&quot;&quot;,&quot; &amp; vValue &amp; &quot;)&quot;&lt;br&gt;
End Select&lt;br&gt;
SetGlobalName = Application.ExecuteExcel4Macro(sCmd)&lt;br&gt;
End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;ve contacted Jan Karel Pieterse, and we&#8217;re working on fitting this into a class module<br />
which will be published on his site later.</p>
<p>This method appears to be stable. No crashes on unregistering, or closing the workbook without unregistering. Can be called from an addin or without activeworkbook. Descriptions DO remain in the Function Wizard when the book is closed, similar to starting and unloading ATP addin.</p>
<p>Using Application.MacroOptions requires an activeworkbook and stores the description and category number in 2 hidden lines in the VBA module.(the category NAME is stored in the workbook itself) This hardcoding may conflict with other addins using the same numbers. This approach does not.</p>
<p>My &#8220;trick&#8221; used to circumvent the 255 character limit is all based on storing the argument values in Excel&#8217;s &#8220;Global namespace&#8221;. (Laurent Longre uses the term &#8220;Hidden Namespace&#8221;). These names exist at application level and can be reached by all workbooks and addins using SET.NAME and GET.NAME macro functions</p>
<p>Note the &#8220;trick&#8221; also works very well with the Evaluate method, which has a similar 255 char limit..</p>
<p>here comes the code&#8230; hopefully ungarbled when HTML is done with it.</p>
<p>Jurgen</p>
<p>Option Explicit</p>
<p>&#8216;This is the function we want to &#8216;describe&#8217; in the Function Wizard<br />
&#8216;Note the function is Private to avoid appearance in &#8216;User Defined&#8217; category<br />
Private Function Occurs(sText$, sPhrase$)<br />
With Application<br />
  Occurs = (Len(sText) &#8211; Len(.Substitute(sText, sPhrase, _<br />
      &#8220;&#8221;))) / .Max(1, Len(sPhrase))<br />
End With<br />
End Function</p>
<p>&#8216;This is the sample procedure to enter the function and argument<br />
&#8216;descriptions for use in the Function Wizard<br />
Sub DescribeIT()<br />
&#8216;keepITcool 2006-02-22</p>
<p>&#8216;Notes:<br />
&#8216;Argument 1 must be a Dll name (as used in API declarations)<br />
&#8216;Argument 2 must be a unique procedure with the dll<br />
&#8216;Argument 3 should not be changed<br />
&#8216;Argument 6 should not be changed</p>
<p>&#8216;For documentation on REGISTER()<br />
&#8216;see macrofun.hlp and/or excel97sdk.chm</p>
<p>&#8216;Store the arguments in Excel&#8217;s name space using SET.NAME<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
SetGlobalName &#8220;arg1?, &#8220;user32.dll&#8221;       &#8216;module_text<br />
SetGlobalName &#8220;arg2?, &#8220;CharNextA&#8221;        &#8216;procedure<br />
SetGlobalName &#8220;arg3?, &#8220;P&#8221;                &#8216;type_text<br />
SetGlobalName &#8220;arg4?, &#8220;Occurs&#8221;           &#8216;function_text<br />
SetGlobalName &#8220;arg5?, &#8220;Text,Phrase&#8221;      &#8216;argument_text<br />
SetGlobalName &#8220;arg6?, 1                  &#8216;macro_type<br />
SetGlobalName &#8220;arg7?, &#8220;Cool Functions&#8221;   &#8216;category<br />
SetGlobalName &#8220;arg8?, &#8220;&#8221;                 &#8216;shortcut_text<br />
SetGlobalName &#8220;arg9?, &#8220;&#8221;                 &#8216;help_topic<br />
&#8216;Function and Argument descriptions<br />
SetGlobalName &#8220;arg10?, &#8220;returns the number of times &#8221; &amp; _<br />
    &#8220;a phrase occurs in a text.&#8221;<br />
SetGlobalName &#8220;arg11?, &#8220;is a (cell reference to) &#8221; &amp; _<br />
    &#8220;the text to be searched&#8221;<br />
SetGlobalName &#8220;arg12?, &#8220;is a (cell reference to) &#8221; &amp; _<br />
    &#8220;the phrase to search for.&#8221;</p>
<p>&#8216;Now Register your function<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Application.ExecuteExcel4Macro _<br />
    &#8220;REGISTER(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)&#8221;<br />
&#8216;Block access to the function pointer (could possibly be CALLed in xl97)<br />
Application.ExecuteExcel4Macro &#8220;SET.NAME(arg4,0)&#8221;</p>
<p>&#8216;Now remove the argument names<br />
&#8216;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
Dim i%<br />
For i = 1 To 12<br />
  SetGlobalName (&#8220;arg&#8221; &amp; i)<br />
Next<br />
End Sub</p>
<p>Sub UnDescribeIT()<br />
Application.ExecuteExcel4Macro _<br />
    &#8220;UNREGISTER(REGISTER.ID(&#8220;&#8221;user32?&#8221;,&#8221;"CharNextA&#8221;"))&#8221;<br />
End Sub</p>
<p>Function SetGlobalName(sName As String, Optional ByVal vValue)<br />
&#8216;Wrapper function for the SET.NAME xlm command<br />
&#8216;If called without the optional vValue the name is DELETED.<br />
Dim sCmd$<br />
Select Case True<br />
  Case IsMissing(vValue)<br />
    sCmd = &#8220;SET.NAME(&#8220;&#8221;" &amp; sName &amp; &#8220;&#8221;")&#8221;<br />
  Case TypeName(vValue) = &#8220;String&#8221; Or IsEmpty(vValue)<br />
    sCmd = &#8220;SET.NAME(&#8220;&#8221;" &amp; sName &amp; &#8220;&#8221;",&#8221;"&#8221; &amp; vValue &amp; &#8220;&#8221;")&#8221;<br />
  Case IsArray(vValue)<br />
    &#8216;Arrays s/b passed as a string like &#8216;{1,2,3}&#8217;<br />
    SetGlobalName = CVErr(xlErrValue)<br />
    Exit Function<br />
  Case Else<br />
    With Application<br />
      vValue = .Substitute(CStr(vValue), .DecimalSeparator, &#8220;.&#8221;)<br />
    End With<br />
    sCmd = &#8220;SET.NAME(&#8220;&#8221;" &amp; sName &amp; &#8220;&#8221;",&#8221; &amp; vValue &amp; &#8220;)&#8221;<br />
End Select<br />
SetGlobalName = Application.ExecuteExcel4Macro(sCmd)<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jkpieterse</title>
		<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/#comment-18914</link>
		<dc:creator>jkpieterse</dc:creator>
		<pubDate>Mon, 20 Feb 2006 08:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1350#comment-18914</guid>
		<description>&lt;p&gt;Looks good Jurgen.&lt;/p&gt;
&lt;p&gt;Any similarity with what I tried to piece together?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Looks good Jurgen.</p>
<p>Any similarity with what I tried to piece together?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keepITcool</title>
		<link>http://www.dailydoseofexcel.com/archives/2006/02/17/registering-a-user-defined-function-with-excel/#comment-18913</link>
		<dc:creator>keepITcool</dc:creator>
		<pubDate>Mon, 20 Feb 2006 04:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1350#comment-18913</guid>
		<description>&lt;p&gt;I have a way around ExecuteExcel4Macro&#039;s 255 char limit, entirely from vba without the macrosheet. No problems when invoked from addin. I&#039;m working on a documenting and testing my code. &lt;/p&gt;
&lt;p&gt;John, afaik Category problems are caused by Analysis Toolpak, some of those functions are hardcoded into Category 15 (Engineering). I&#039;ll try to find a trick for that too.&lt;/p&gt;
&lt;p&gt;If interested drop me a mail, else i&#039;ll post here soon.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I have a way around ExecuteExcel4Macro&#8217;s 255 char limit, entirely from vba without the macrosheet. No problems when invoked from addin. I&#8217;m working on a documenting and testing my code. </p>
<p>John, afaik Category problems are caused by Analysis Toolpak, some of those functions are hardcoded into Category 15 (Engineering). I&#8217;ll try to find a trick for that too.</p>
<p>If interested drop me a mail, else i&#8217;ll post here soon.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

