从文本框中读取值

问题描述 投票:0回答:1

[嗨,我正尝试从Google幻灯片中创建的文本框中读取值

因此,我通过为数组中的每个值调用此函数来创建多个文本框

function newTextBox(textBoxID, xpos, ypos, textBoxText) {

var elementId = textBoxID;
var requests = [{
  createShape: {
    objectId: elementId,
    shapeType: 'TEXT_BOX',
    elementProperties: {
      pageObjectId: pageId,   
      'size': {
        'width': {
          'magnitude': 53.5748,
          'unit': 'PT'
        },
        'height': {
          'magnitude': 22.6772,
          'unit': 'PT'
        }

      },
      transform: {
        scaleX: 1,
        scaleY: 1,
        translateX: xpos,
        translateY: ypos,
        unit: 'PT'
      }
    }
  }
},

// Insert text into the box, using the supplied element ID.
{
  insertText: {
    objectId: elementId,
    insertionIndex: 0,
    text: textBoxText
  }
}];

// Execute the request.
var createTextboxWithTextResponse = Slides.Presentations.batchUpdate({
  requests: requests
}, presentationId);
var createShapeResponse = createTextboxWithTextResponse.replies[0].createShape;
console.log('Created textbox with ID: %s', createShapeResponse.objectId);
}

所以textBoxID是我定义的ID,以便以后参考。 textBoxText最初设置为0。

该脚本的目的是将文本框中的每个值与我拥有的数组中的值进行比较。然后进行计算,然后更新值。我已经看到许多类似的问题,但似乎找不到正确的答案。

我不想只更新值,我特别需要读取值。我基本上需要的是类似textBoxID[1].getText()的东西,但是我找不到类似的东西/可以实现相同目标的东西。任何帮助将被大大接受

google-apps-script textbox google-slides-api google-slides
1个回答
0
投票
textBoxID的文本框不存在时,您要创建新的文本框。
    textBoxID的文本框存在时,您想要修改文本框中的值。
© www.soinside.com 2019 - 2024. All rights reserved.