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:
using Microsoft.Office.Interop.Excel;
Application xlApp;
Workbook xlWorkBook;
Worksheet xlWorkSheet;
// create application, open workbook, etc ...
// now try to register xll
xlApp.RegisterXLL("C:\\SomePath\\Whatever.xll");
However, this always return false. I try to see what Excel secretly does when I load the xll manually by recording the macro. The macro looks like:
Sub Macro1()
ChDir "C:\SomePath"
Application.RegisterXLL Filename:= _
"C:\SomePath\Whatever.xll"
End Sub
The only difference seems to be the ChDir, so I changed my code to:
FileSystem.ChDir("C:\\SomePath");
xlApp.RegisterXLL("C:\\SomePath\\Whatever.xll");
But it still doesn't work. Another odd thing is when I put a breakpoint before the RegisterXLL line and load the xll manually first, the RegisterXLL method will return true. But otherwise, it will return false.