提问人:ammcom 提问时间:11/7/2023 更新时间:11/10/2023 访问量:28
Powerpoint 加载项 javascript api RichApi.Error:GeneralException
Powerpoint add-in javascript api RichApi.Error: GeneralException
问:
我正在尝试为 MS PowerPoint 构建一个加载项,因此我决定测试文档中的一个示例,即:
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/text/get-set-textrange.yaml
// Selects the first 10 characters of the selected shape.
await PowerPoint.run(async (context) => {
const shapes = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
await context.sync();
if (shapeCount.value !== 1) {
console.warn("You must select only one shape with text in it.");
return;
}
const shape = shapes.getItemAt(0);
const textFrame = shape.textFrame.load("textRange,hasText");
await context.sync();
if (textFrame.hasText != true) {
console.warn("You must select only one shape with text in it.");
return;
}
const textRange = textFrame.textRange;
textRange.load("text");
await context.sync();
if (textRange.text.length < 10) {
console.warn("You must select only one shape with at least 10 characters in it.");
return;
}
const textRange10 = textRange.getSubstring(0, 10);
textRange10.setSelected();
await context.sync();
});
在 MS PowerPoint 上运行代码时,加载 textRange 的行会引发异常:await context.sync();
异常 RichApi.Error:GeneralException
我尽我所能,但没有成功,任何帮助都是值得赞赏的
答:
1赞
mabarif
11/10/2023
#1
这是 Powerpoint Web 中的一个错误
我遇到了类似的错误,并决定将其报告给Microsoft:https://github.com/OfficeDev/office-js/issues/3826
他们一致认为这是一个错误,现在正在调查它。
评论