I am creating an AddIn office that works in both excel and word applications and on a host basis, if it is a word or excel host, I want to execute different logic. I am using office.js to create an Office Addin.
eg: -
let say type="Excel" // after some logic executed if(type=="Excel") { //run code for excel applications } else { //run code for word applications }
I tried using a roar: -
if (Office.context.requirements.isSetSupported('ExcelApi', '1.1')) { alert("yes it is excel"); }
but it does not work when I run it in excel.
I also sent the host to the manifest file
<Hosts> <Host Name="Document" /> <Host Name="Workbook" /> </Hosts>
Also, I have a code that changes a lot, I found the following code that does not work for me
function getHostInfo() { var _requirements = Office.context.requirements; var types = ['Excel', 'Word']; var minVersions = ['1.1', '1.0']; // Start with the highest version // Loop through types and minVersions for (var type in types) { for (var minVersion in minVersions) { // Append "Api" to the type for set name, ie "ExcelApi" or "WordApi" if (_requirements.isSetSupported(types[type] + 'Api', minVersions[minVersion])) { return { type: types[type], apiVersion: minVersions[minVersion] } } } } };
thanks
source share