OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
641 stars 92 forks source link

When PowerPoint shape is a table, reference to the Shape.TextFrame property throws InvalidArgument error #4380

Closed Rick-Kirkham closed 3 weeks ago

Rick-Kirkham commented 1 month ago

Provide required information needed to triage your issue

Tables added to a slide by the user are treated as shapes in the PowerPoint APIs. But any reference to the shape's TextFrame property throws an InvalidArgument error.

Your Environment

Expected behavior

A reference to the Shape.TextFrame property should not throw any errors.

Current behavior

Tables added to a slide by the user are treated as shapes in the PowerPoint APIs. But any reference to the shape's TextFrame property throws an InvalidArgument error.

Steps to reproduce

  1. In Script Lab, remove all shapes from a slide.
  2. Add a table to a slide so it is the only shape on the slide.
  3. Select the shape.
  4. Run this code.
  await PowerPoint.run(async (context) => {
    const shapes = context.presentation.getSelectedShapes();
    const myshape = shapes.getItemAt(0);
    myshape.load();
    await context.sync();
    console.log(JSON.stringify(myshape,null,4));
    console.log(myshape.id);
    console.log(JSON.stringify(myshape.lineFormat));
    console.log(myshape.name);

    // The next line throws InvalidArgument error and specifies line "var textFrame = selectedShape.textFrame;"

    myshape.textFrame.load("isNullObject");  
    await context.sync();
    if (!myshape.textFrame.isNullObject) {
      console.log(JSON.stringify(myshape.textFrame));
      console.log(JSON.stringify(myshape.textFrame.textRange));
      myshape.textFrame.textRange.load("text");
      await context.sync();
      console.log(JSON.stringify(myshape.textFrame.textRange.text));
    } else {
      console.log("textFrame is a null objext");
    }
  });

Context

This customer is blocked: https://stackoverflow.com/questions/78347608/how-to-update-data-in-powerpoint-table-using-office-js

samantharamon commented 1 month ago

Thanks for reporting this, @Rick-Kirkham.

@EsterBergen, could you please investigate this issue?

EsterBergen commented 1 month ago

@Rick-Kirkham - Thanks! From the stack overflow, it sounds like there is desire to insert and modify tables via office.js. Can you confirm.? That functionality is not currently available but being worked on. https://stackoverflow.com/questions/78347608/how-to-update-data-in-powerpoint-table-using-office-js

microsoft-github-policy-service[bot] commented 3 weeks ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

microsoft-github-policy-service[bot] commented 3 weeks ago

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.