CBleunven
12 years agoContributor
Running Excel as COM object "disable" add-ins
Hi everybody,
We have an add-in for excel for another application and I face a problem with running Excel as a COM object using the following code:
var Excel = Sys["OleObject"]("Excel.Application");
Excel["Workbooks"]["Open"](anExcelFilePath);
Excel["Visible"] = true;
The add-in is not functionnal. If I start Excel manually, the add-in is visible in the ribbon and is OK. If I start Excel through the code upstair, the add-in is not visible and not functional (formula are not calculated and return a #NAME? error).
But, from this Excel instance, if I go under File/Option/Add-Ins, the add-in is present in the "Active Application Add-ins" section.
Is there a way I can run Excel from TC with Add-ins activated ? I need to update some values in the excel sheet before getting results, so I guess DB Table or DDTDriver will not be suitable.
Thank you for help,
regards,
Christophe
EDIT : sorry I've just seen I didn't post in the correct section.
We have an add-in for excel for another application and I face a problem with running Excel as a COM object using the following code:
var Excel = Sys["OleObject"]("Excel.Application");
Excel["Workbooks"]["Open"](anExcelFilePath);
Excel["Visible"] = true;
The add-in is not functionnal. If I start Excel manually, the add-in is visible in the ribbon and is OK. If I start Excel through the code upstair, the add-in is not visible and not functional (formula are not calculated and return a #NAME? error).
But, from this Excel instance, if I go under File/Option/Add-Ins, the add-in is present in the "Active Application Add-ins" section.
Is there a way I can run Excel from TC with Add-ins activated ? I need to update some values in the excel sheet before getting results, so I guess DB Table or DDTDriver will not be suitable.
Thank you for help,
regards,
Christophe
EDIT : sorry I've just seen I didn't post in the correct section.
- Is there a reason you cannot just re-write the one formula in script?
Also this is from MSDN:To load an add-in file when you run Excel as an OLE Automation object, load the add-in manually. Examples of this method are as follows.
Microsoft Office Excel 2007
Sub LoadAddin()
' Dimension variable xl as object type.
Dim xl As Object
' Activate Microsoft Excel and assign to variable xl.
Set XL = CreateObject("Excel.Application")
' Open the add-in file you want, in this example, XLQUERY.XLAM.
XL.Workbooks.Open (XL.librarypath & "\MSQUERY\XLQUERY.XLAM")
' If you need to register the functions and commands
' contained in a resource (XLL), use the RegisterXLL method.
' In the example below, all functions of Analys32.xll are
' registered.
' XL.RegisterXLL "Analys32.xll"
' Run any auto macros contained in the add-in file
' Auto macros don't run when you open a file
' using the Open method.
XL.Workbooks("xlquery.xlam").RunAutoMacros 1
Set XL = Nothing
End Sub
Microsoft Office Excel 2003 and earlier versions of Excel
Sub LoadAddin()
' Dimension variable xl as object type.
Dim xl As Object
' Activate Microsoft Excel and assign to variable xl.
Set XL = CreateObject("Excel.Application")
' Open the add-in file you want, in this example, XLQUERY.XLA.
XL.Workbooks.Open (XL.librarypath & "\MSQUERY\XLQUERY.XLA")
' If you need to register the functions and commands
' contained in a resource (XLL), use the RegisterXLL method.
' In the example below, all functions of Analys32.xll are
' registered.
' XL.RegisterXLL "Analys32.xll"
' Run any auto macros contained in the add-in file
' Auto macros don't run when you open a file
' using the Open method.
XL.Workbooks("xlquery.xla").RunAutoMacros 1
Set XL = Nothing
End Sub