Can I edit table in powpoint by office-js now?

176 Views Asked by At

I want to reshape all selected items in PowerPoint by office-js.

But all the table's shape.type are "Unsupported" and the code below can not change the table width.

async function resizeSelectedShapes() {
  await PowerPoint.run(async (context) => {
    // First, get the current selection
    const selection = context.presentation.getSelectedShapes();
    selection.load("items");
    const shapeCounts = selection.getCount();
    await context.sync();

    selection.items.map((shape) => {
      shape.load("left,right,width,height");
    });
    await context.sync();
    const rsize = 0.8;
    selection.items.map((shape) => {
      shape.left *= 0.8;
      console.log(shape.type);
      shape.width *= 0.8;
      if (shape.type == "Image") {
        shape.height *= 0.8;
      }
    });
  });
}

I found I can use table in powerpoint web version, so access table in PowerPoint in office-js is possible or not?

1

There are 1 best solutions below

2
On

The supported list of shapes are defined in the PowerPoint.ShapeType enum. As you can see, there is no table in the list of supported shapes. So, you may post or vote for an existing feature request on Tech Community where they are considered when the Office dev team go through the planning process.

You may find the Work with shapes using the PowerPoint JavaScript API page helpful.