I am trying to manipulate a table in Google Slides, but there seem to be documented operations that throw errors in AppScript.
https://developers.google.com/apps-script/reference/slides/table
The commented out lines throw the following errors:
Updating the size of this page element type is not supported.
var table = (slides[page])
.insertTable(rows, columns)
.setTop (0)
.setLeft(0)
//.setWidth(presentation.getPageWidth());
//.setHeight(presentation.getPageHeight());
How about this answer? I have also confirmed the same situation with you. I think that this might be a bug. Because when Slides API is used, the table which adjusted the width and height can be created. So in the current workaround, when the size of the table is required to be adjusted when the table is created, I create the table using Slides API. The sample script is as follows.
In order to use the sample script, before you run the script, please enable Slides API at Advanced Google Services and API console as follows.
When your script is modified using Slides API, it becomes as follows.
var presentation = SlidesApp.getActivePresentation();
var slides = presentation.getSlides();
var resource = {"requests":[{"createTable": {
"rows": 2,
"columns": 3,
"elementProperties": {
"size": {
"width": {"unit": "PT", "magnitude": presentation.getPageWidth()},
"height": {"unit": "PT", "magnitude": presentation.getPageHeight()},
},
"pageObjectId": slides[0].getObjectId()},
}
}]};
Slides.Presentations.batchUpdate(resource, presentation.getId());
If you want to modify the size of the existing table, you can use the following script.
var presentation = SlidesApp.getActivePresentation();
var slides = presentation.getSlides();
var table = slides[0].getTables()[0];
var tableObjectId = table.getObjectId();
var resource = {"requests": [
{"updateTableColumnProperties": {
"objectId": tableObjectId,
"tableColumnProperties": {"columnWidth": {"unit": "PT", "magnitude": presentation.getPageWidth() / table.getNumColumns()}}, "fields": "*"}
},
{"updateTableRowProperties": {
"objectId": tableObjectId,
"tableRowProperties": {"minRowHeight":{"unit": "PT", "magnitude": presentation.getPageHeight() / table.getNumRows()}},"fields":"*"}
}
]};
Slides.Presentations.batchUpdate(resource, presentation.getId());
If this was not the workaround you want, I apologize.