I\'m trying to automating some tests for an Excel add-in, which is in xll form. I have some problem in loading the xll. I\'m writing it in C# and my code looks like this:
I was facing issues with loading user defined function [UDF] in VBA code. Was able to load xll file but wasn't able to call.
Following code successfully loads XLL files and let's call user defined function from VBA code. There may be redudendent instruction in this module but it works!
Sub InstallAddIn()
On Error GoTo ErrorHandle
Application.DefaultFilePath = "D:\\MyFolder"
Application.RegisterXLL ("MyXLLFileName.xll")
Set AI = AddIns.Add(Filename:="D:\MyFolder\MyXLLFileName.xll")
If AddIns("MyXLLFileName").Installed Then
LogInformation ("My XLL is installed")
Else
LogInformation ("My XLL is NOT installed")
End If
Exit Sub
ErrorHandle:
LogInformation ("------------------------") 'Logging function that I have written. Not a std api
LogInformation (Err.HelpFile)
LogInformation (Err.HelpContext)
LogInformation (Err.Description)
LogInformation ("Error in InstallAddIn module")
LogInformation ("------------------------")
End
End Sub