How do I add a comment to a Google Doc with Google Apps Script

匿名 (未验证) 提交于 2019-12-03 01:34:02

问题:

I was looking at the documentation and found no way to add a comment using Google Apps Script.

After scrolling a bit, I found out that the addComment() function was deprecated.

Is there currently any way to add a comment to a Google Doc using GAS (without using a deprecated script)?

回答1:

You can add comments using the Advanced Drive Service (That must be enabled before use. In the Script Editor select Resources > Advanced Google services... and then enable it in the Google Developers Console.)

Once enabled you can create a comment using Comments: insert.

Here's an example:

function myFunction(){   var fileId = '{YOUR_DOCUMENT_ID}';   var resource = {'content': 'Le comment'};    Drive.Comments.insert(resource, fileId) }

Then you can verify the comment in the Comments section of your doc:



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!