是的,可以使用JS API获取和选择PowerPoint中的Alt Text。
以下示例代码演示如何获取文本框中的Alt Text:
Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, { getOnlyData: true, coercionType: Office.CoercionType.Text }, function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
console.log("Error: " + asyncResult.error.message);
}
else {
var selectedText = asyncResult.value;
console.log(selectedText);
}
});
以下示例代码演示如何向PowerPoint幻灯片中添加Alt Text:
Office.context.document.setSelectedDataAsync("Alt Text", { coercionType: Office.CoercionType.Text }, function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
console.log("Error: " + asyncResult.error.message);
}
});