Word-Add in CreateDocument 提供 AccessDenied

huangapple go评论57阅读模式
英文:

Word-Add in CreateDocoment gives AccessDenied

问题

以下是您要翻译的代码部分:

function WordLoadDocument(msg) {
    Word.run(context => {
        var myNewDoc = context.application.createDocument();
        myNewDoc.properties.load();
        /*
        myNewDoc.properties.customProperties.add("fileId", file.id);
        myNewDoc.properties.customProperties.add("fileName", file.name);
        myNewDoc.properties.customProperties.add("attachId", attach.id);
        myNewDoc.properties.customProperties.add("attachName", attach.name);*/
        myNewDoc.open();
        return context.sync()
    }).catch(error => {
        if (error instanceof OfficeExtension.Error) {
            console.log(
                "Error code and message: " + JSON.stringify(error.debugInfo)
            );

        console.log(error)

    }
});

请注意,我已经去掉了HTML实体编码并进行了适当的格式化。希望这可以帮助您理解问题的上下文。如果您需要任何进一步的帮助,请随时提出。

英文:

I've created a simple word plugin and want to create a document based off another document.

I've stripped down the code

function WordLoadDocument(msg) {
        Word.run(context => {
            var myNewDoc = context.application.createDocument();
            myNewDoc.properties.load();
            /*
            myNewDoc.properties.customProperties.add("fileId", file.id);
            myNewDoc.properties.customProperties.add("fileName", file.name);
            myNewDoc.properties.customProperties.add("attachId", attach.id);
            myNewDoc.properties.customProperties.add("attachName", attach.name);*/
            myNewDoc.open();
            return context.sync()
        }).catch(error => {
            if (error instanceof OfficeExtension.Error) {
                console.log(
                    "Error code and message: " + JSON.stringify(error.debugInfo)
                );

            console.log(error)

        }
    });

But I just get
Error code and message: {"code":"AccessDenied","message":"AccessDenied","errorLocation":"Application.createDocument","statement":"var createDocument = v.createDocument();"...

It doesn't seem to matter what I do I just always get the error - even before I add in the data..

The manifest has ReadWriteDocument which seems to be the 'max'
https://learn.microsoft.com/en-us/javascript/api/manifest/permissions?view=word-js-1.4

Is there something I'm missing.
I'm on Word desktop and sideloading the app via network - could this be a permissions on the machine / type issue?

答案1

得分: 0

所以我已经解决了这个问题 - 基本上问题是我在对话框中使用了这个加载项(displayDialogAsync)。Word不喜欢这样做,因此出现了错误。

英文:

So I've worked this one out - basically the issue is that I had the add-in in a dialog box (displayDialogAsync). Word doesn't like it and hence the error.

huangapple
  • 本文由 发表于 2023年2月6日 19:24:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75360673.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定