I was wondering, how could we programmatically disable Excel UDF in C#?
I guess perhaps we might have to manipulate registry keys to achieve this. But what subkeys should I be looking at here? I don’t want to accidentally destroy the whole subkey tree structure. Can anyone give me some help please?
The registry key structure
HKEY_CLASSES_ROOT
- CLSID
- {MYCLASSID}
- Implemented Categories
- InprocServer32 **(got quite a few subkeys within, perhaps this one?)**
- ProgId
- Programmable
Fortunately, I think I have found the answer myself.
It appears that
(default)value of subkey InprocServer32 controls the Excel UDF. If its value is set to empty, UDF will not be recognized by the automation server, thus showing #Name mark in the cell, which is pretty much all I need here in this case.If I want to enable Excel UDF, just set its value to C:\WINDOWS\system32\mscoree.dll, and UDF will be available again.