1

I used MacroOptions method to add descriptions for UDF. How to clear/unregister UDF descriptions?

This code works:

Application.MacroOptions Macro:=Fname, Description:=Empty, Category:=Empty

But this codes doesn't work:

Application.MacroOptions Macro:=Fname, Description:=Empty, Category:=Empty, ArgumentDescriptions:=Empty

Because of ArgumentDescriptions:=Empty , the code makes error 1004.

FunThomas
  • 23,043
  • 3
  • 18
  • 34
AliM67
  • 123
  • 12

2 Answers2

1

As described here, Macro, Description and Category are Variant parameters.

ArgumentDescriptions is an Array, containing descriptions of the UDF function arguments.

So, its value to cancel existing cannot be Emmpty!

Even if using:

 Application.MacroOptions Macro:=Fname, Description:=Empty, Category:=Empty

In order to also unregister ArgumentDescriptions you should use

 Application.MacroOptions Macro:=Fname, Description:=Empty, Category:=Empty, ArgumentDescriptions:=arrDescr

Where arrDescr was the array used to set ArgumentDescriptions when you registered it. Something like:

Dim arrDescr
arrDescr = Split("Description for first argument,Description for second argument,Descr for thirt one",",")

Application.MacroOptions Macro:="Fname", Description:="It does things", Category:=9, ArgumentDescriptions:=arrDescr
FaneDuru
  • 38,298
  • 4
  • 19
  • 27
  • With Unregistering without ArgumentDescriptions still descriptions remains. Also, ArgumentDescriptions:=Null can't clear them. – AliM67 Jul 29 '22 at 18:53
  • Ups... Did not check it as it should. I remember now that you should use the same array you used when register the UDF function! I will edit the answer and give an example. – FaneDuru Jul 29 '22 at 19:00
  • @AliM67 Edited the answer and corrected... – FaneDuru Jul 29 '22 at 19:06
  • Thanks but it isn't my ideal. I have many UDF and I like clear totally without worrying about how many arguments is determined before. – AliM67 Jul 29 '22 at 19:14
  • @AliM67 it may not be your ideal, but I am afraid that this is the way Microsoft designed the way of unregistering... Do you need unregistering of all of them? Don't you have the functions used to register them? If so, you can make a sub searching for `Application.MacroOptions`, then extracting the used array content. Not very simple, but possible, I think. – FaneDuru Jul 29 '22 at 19:26
0

After some researches, I couldn't find any document how to Unregister the UDF descriptions. Finally I find a trick. To clear ArgumentDescriptions It doesn't need to know how many arguments is determined before. Below code clears all of them. Just should define an array with 1 empty element.

Dim arrEmpty(0)
Application.MacroOptions Macro:=Fname, Description:=Empty, Category:=Empty, ArgumentDescriptions:=arrEmpty
AliM67
  • 123
  • 12