Skip to content

Instantly share code, notes, and snippets.

@davecra
Created July 3, 2017 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davecra/cc1967d9f627c6fbe45fbef868a0effc to your computer and use it in GitHub Desktop.
Save davecra/cc1967d9f627c6fbe45fbef868a0effc to your computer and use it in GitHub Desktop.
Gets the host application name
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