Skip to content

Instantly share code, notes, and snippets.

@davecra
Created June 15, 2020 19:55
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/88e8eb57481da9d8edd2b8123a238221 to your computer and use it in GitHub Desktop.
Save davecra/88e8eb57481da9d8edd2b8123a238221 to your computer and use it in GitHub Desktop.
This is the code from a Task Pane Add-in that sends a message to a Content Add-in via a CustomXMLPart
const ns = "http://pfe.microsoft.com/excelpoc/1.0";
const xml = "<message xmlns='http://pfe.microsoft.com/excelpoc/1.0'>" +
"<sentby>[who]</sentby>" +
"<info>[data]</info>" +
"</message>";
const from_tp = "TASKPANE ADD-IN";
function sendMessage() {
Excel.run(function(context) {
var data = xml.replace("[who]", from_tp).replace("[data]", "This message is coming from the taskpane.");
const customXmlPart = context.workbook.customXmlParts.add(data);
customXmlPart.load();
return context.sync().then();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment