I'm working on a VSTO add-in. I don't want to write UDFs in it, although i know how to write it following COM stuff, or using ExcelDNA. Instead, i just want to include one of the existing xlam add-ins, which contains loads of UDFs. So when people install the VSTO add-in, i also want the xlam add-in to be installed. so i've written this code in ThisAddin_startup event.
bool isExist=false;
foreach (Excel.AddIn a in Application.AddIns)
{
if (a.Name=="foobar.xlam")
{
if (!a.Installed)
a.Installed = true;
isExist = true;
break;
}
}
if (isExist==false)
this.Application.AddIns.Add(pathtotheaddin).Installed = true; //it is inside the resources folder
But i keep getting "Add method of AddIns class failed" error. What am i doing wrong?
I've found it finally. It's because there are no workbooks open yet, so it can't install any add-ins. You know that when there is no workbook open yet, add-ins button is disabled.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.