英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论