如何通过Google Apps脚本从Google文档中的位置确定命名范围 [英] How to determine the named range from position in Google Docs through Google Apps Script

查看:102
本文介绍了如何通过Google Apps脚本从Google文档中的位置确定命名范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法,可以通过Google Apps脚本为当前光标位置确定Google文档中的命名范围.反正有这样做吗?

I am looking at a way to determine the named range in Google docs through Google Apps Script for the current cursor position. Is there anyway to do that?

上下文: 我在Google文档中标记了一个范围,以使用命名范围进行审核.如果要将光标放在文档的该位置,我想获取命名范围,以便可以显示该区域上有一个审阅项目.

Context: I am marking a range in the google document for review using named range. I would like to get the named range if the cursor is placed in that location of the document so that I can show that there is a review item on that area.

能否让我知道Google Apps脚本中是否可以执行此操作? 谢谢 碧玉

Could you please let me know if there is a way to do that in Google Apps Script? thanks Jasper

推荐答案

var cursor = DocumentApp.getActiveDocument().getCursor();

光标是一个位置".

位置"可以告诉您几件事,例如保持位置的元素. 注意:关于职位的想法是完全相反的: 职位不能包含其他元素. 职位包含在 内.

A "Position" can tell you several things, for example the element which holds the position. Be careful: The thinking of a position is quite opposite: A position cannot contain other elements. A position is contained within an element.

因此,我认为您可以搜索此元素的命名范围:

So i think you could search your named ranges for this element:

cursor.getElement()

我认为,如果必须进行匹配,则必须遍历您的范围……宾果游戏.

You have to iterate through your ranges, i think and if there is a match ... bingo.

让我知道这是否有帮助.

Let me know if this helps.

这篇关于如何通过Google Apps脚本从Google文档中的位置确定命名范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆