In Excel, it is possible to assign help file (e.g. chm file) to a user-defined function using VBA code, Application.MacroOptions method. So, I faced a strange issue with it.
Suppose that we wrote the UDF named as "myUDF()".
Function myUDF()
myUDF = "it is test"
End Function
When you open Function Wizard for it, and click on "Help on this function", Excel get error : "No help available."
So, we run below code to assign help file to it:
Sub SetHelpFile()
Application.MacroOptions _
Macro:="'" & ThisWorkbook.Name & "'!" & "myUDF", _
HelpFile:=ThisWorkbook.Path & "\CHM-example.chm", _
HelpContextID:=10010
End Sub
It is necessary that chm file contains Topic ID. I used chm file from this sample. After running the code, chm file is assigned to UDF. But there is a problem. If you click on "Help on this function", it can't show specific page according mentioned topic ID (for this sample: 10010)
It is more complicate If you run code SetHelpFile again. After that If you click on "Help on this function", it show correct page.
I don't know what's the problem. Is it a bug?
EDIT: To reproduce the issue, you can get this file and test it!