forked from MIchaelMainer/Add-in-TaskPane-Sample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
21 lines (19 loc) · 683 Bytes
/
script.js
File metadata and controls
21 lines (19 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// The initialize function must be run each time a new page is loaded
Office.initialize = function (reason) {
$(document).ready(function () {
$('#get-data-from-selection').click(getDataFromSelection);
});
};
// Reads data from current document selection and displays a notification
function getDataFromSelection() {
console.log("getDataFromSelection called");
Office.context.document.getSelectedDataAsync(Office.CoercionType.Text,
function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
$('#display-data').text('The selected text is: ' + result.value);
} else {
$('#display-data').text('Error: ' + result.error.message);
}
}
);
}