为什么pasteHTML报(in promise) TypeError: Cannot create property 'message' on string 'service copy fail'

阅读次数 1

(in promise) TypeError: Cannot create property 'message' on string 'service copy fail' 内容控件,经过一些缓存处理,有什么方法,知道具体原因?

2 Answers

老哥 你用过这个 API 么 await app.ActiveDocument.Find.Execute('南京', true) word 模式 我掉这个没反应 我debugger 看里面 内部 error 了,有遇到过这个情况么

    const doc = await this.wpsApp.ActiveDocument;
    if(true) {
        const controls = await doc.ContentControls;
        const c1 = await controls.Item(1);
        const c1Range = await c1.Range;
        const old = await c1Range.GetHtmlData();
        await c1Range.PasteHtml({ HTML: old.HTML });
        return;
    } 为什么这么简单的代码也报错,service copy fail

原因是因为内容控件处于锁定状态,解锁后,可以PasteHTML, 错误消息和这个毫无关系

通过后台返回解锁状态的控件,解决!