Created
July 3, 2017 14:40
-
-
Save davecra/cc1967d9f627c6fbe45fbef868a0effc to your computer and use it in GitHub Desktop.
Gets the host application name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var current; | |
app.hostTypes = { Word :"Word", PowerPoint :"PowerPoint", Excel :"Excel"}; | |
app.getHost = function () { | |
if (current == null) { | |
if (Office.context.requirements.isSetSupported('WordApi')) { | |
current = app.hostTypes.Word; | |
} else if (Office.context.requirements.isSetSupported('ExcelApi')) { | |
current = app.hostTypes.Excel; | |
} else { | |
var host = $.urlParam("_host_Info"); | |
if (host.toLowerCase().indexOf("word",0) >= 0) { | |
current = app.hostTypes.Word; | |
} else if (host.toLowerCase().indexOf("excel",0) >= 0) { | |
current = app.hostTypes.Excel; | |
} else { | |
current = app.hostTypes.PowerPoint; | |
} | |
} | |
return current; | |
} | |
else { | |
return current; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment