Google apps script 更改附着到InlineDrawing对象的链接
此问题已交叉发布到Web应用程序: 这是我的谷歌文档: 您可以在其中看到一个名为“输入新注释”的按钮 我已经成功地滚动了文档的元素,找到了表,并根据需要替换了这些区域中的txt。但是这里的按钮需要更改URL,我不知道怎么做 这个URL似乎给出了一个想法,但我不能把它变成我的答案,因为我不太明白 有人能帮我展示一下实际的代码吗?因为我试着编辑了很多关于元素、setURL和查找父元素等的例子,结果弄得一团糟 我从谷歌的工作表中调用脚本,在一堆谷歌文档上工作。(我将通过电子表格获取下一个文档的URL,以替换其URL 这是我所相信的最接近的地方:Google apps script 更改附着到InlineDrawing对象的链接,google-apps-script,google-docs,Google Apps Script,Google Docs,此问题已交叉发布到Web应用程序: 这是我的谷歌文档: 您可以在其中看到一个名为“输入新注释”的按钮 我已经成功地滚动了文档的元素,找到了表,并根据需要替换了这些区域中的txt。但是这里的按钮需要更改URL,我不知道怎么做 这个URL似乎给出了一个想法,但我不能把它变成我的答案,因为我不太明白 有人能帮我展示一下实际的代码吗?因为我试着编辑了很多关于元素、setURL和查找父元素等的例子,结果弄得一团糟 我从谷歌的工作表中调用脚本,在一堆谷歌文档上工作。(我将通过电子表格获取下一个文档的URL
function getDocElements() {
var doc = DocumentApp.openByUrl("https://docs.google.com/document/d/1TgzOIq0g4DyDefmJIEnqycDITIx_2GNQkpdxMGwtqB8/edit?usp=sharing"),
body = doc.getBody(),
numElements = doc.getNumChildren(),
elements = [];
for (var i = 0; i < numElements; ++i){
var element = doc.getChild(i),
type = element.getType();
// daURL = element.getURL();
// Look for child elements within the paragraph. Inline Drawings are children.
// if(element.asParagraph().getNumChildren() !=0 && element.asParagraph().getChild(0).getType() == DocumentApp.ElementType.INLINE_DRAWING) {
var drawingRange = body.findElement(DocumentApp.ElementType.INLINE_DRAWING);
while (drawingRange != null) {
var element = drawingRange.getElement();
var drawingElement = element.asInlineDrawing();
//drawingElement.removeFromParent();
drawingElement.setURL("http://www.google.com");
drawingRange = body.findElement(DocumentApp.ElementType.INLINE_DRAWING);
}
// For whatever reason, drawings don't have their own methods in the InlineDrawing class. This bit copies and adds it to the bottom of the doc.
//var drawing = element.asParagraph().copy();
//body.appendParagraph(drawing);
}
Logger.log(i + " : "+type);
}
函数getDocElements(){
var doc=DocumentApp.openByUrl(“https://docs.google.com/document/d/1TgzOIq0g4DyDefmJIEnqycDITIx_2GNQkpdxMGwtqB8/edit?usp=sharing"),
body=doc.getBody(),
numElements=doc.getNumChildren(),
元素=[];
对于(变量i=0;ifunction getDocElement() {
var doc = DocumentApp.openByUrl("https://docs.google.com/document/d/1TgzOIq0g4DyDefmJIEnqycDITIx_2GNQkpdxMGwtqB8/edit?usp=sharing"),
body = doc.getBody(),
numElements = doc.getNumChildren(),
elements = [];
for (var i = 0; i < numElements; ++i){
var element = doc.getChild(i),
type = element.getType();
// daURL = element.getURL();
Logger.log(i + " : " + numElements + " : "+ type + " " + element);
// Search through the page elements. Paragraphs are top-level, which is why I start with those.
if( type == DocumentApp.ElementType.PARAGRAPH ){
// Look for child elements within the paragraph. Inline Drawings are children.
if(element.asParagraph().getNumChildren() !=0 && element.asParagraph().getChild(0).getType() == DocumentApp.ElementType.INLINE_DRAWING) {
//element.getParent().setLinkUrl("http://www.google.com");
Logger.log(element.asParagraph().getChild(0).getType() + " : " + element.getAttributes());
// For whatever reason, drawings don't have their own methods in the InlineDrawing class. This bit copies and adds it to the bottom of the doc.
var drawing = element.asParagraph().copy();
//body.appendParagraph(drawing);
// body.appendParagraph();
if(element.getParent() !=''){
//element.asParagraph().appendHorizontalRule();
//element.editAsText().appendText("text");
// element.getParent().insertHorizontalRule(0);
}
}
}
}
}
函数getDocElement(){
var doc=DocumentApp.openByUrl(“https://docs.google.com/document/d/1TgzOIq0g4DyDefmJIEnqycDITIx_2GNQkpdxMGwtqB8/edit?usp=sharing"),
body=doc.getBody(),
numElements=doc.getNumChildren(),
元素=[];
对于(变量i=0;i- 问题:允许将内嵌图形导出为图像
- 问题:添加创建和修改图形的功能
1:Henrique Abreu to不幸的是,InlineDrawing类没有访问附加链接的方法,也没有任何其他方法以编程方式将其更改为InlineImage1。在我看来,您必须手动更改链接 相关功能请求:
- 问题:允许将内嵌图形导出为图像
- 问题:添加创建和修改图形的功能
1:Henrique Abreu to最终,我必须将每个文档的URL按钮更改为一个新的URL,我将从电子表格中获取该URL。相关:最终,我必须将每个文档的URL按钮更改为一个新的URL,我将从电子表格中获取该URL。相关:我认为您正在向我展示如何设置图像的URL,并建议我替换该图形我不知道我该怎么做。另外,这是一个测试,因为我有600多个文件夹,其中包含这些必须完成的文档,因此,编写脚本来找到解决方案几乎是必须的。请@ocordova,告诉我如何用文档URL列表中的图像替换图形?这是唯一的建议这可能不管用。事实上,我很惊讶没有人能够以深厚的专业知识对此做出回应。内联绘图是否如此罕见?这不是一个健康的过程,以这种方式构建按钮,这是互联网上的建议吗?遗憾的是,目前没有setLinkUrl方法。我向chan建议