Skip to content

PowerPoint: no way to select or reach a TextRange for text inside a table cell — TableCell has no textRange/setSelected, and Shape.textFrame throws for table shapes #6906

Description

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: Mac desktop (but this is an API surface gap, so it reproduces on all platforms including Office on the web)
  • Host: PowerPoint
  • Office version number: 16.112.2 (build 26082125), Microsoft 365 Subscription — typings up to PowerPointApi 1.10 / preview
  • Operating System: macOS 26 (Darwin 25.6.0)
  • Browser (if using Office on the web): N/A (also reproduces in any browser)

Expected behavior

There should be some path from a table cell to a PowerPoint.TextRange, so that a sub-range of the cell's text can be selected in the view, e.g.:

const cell = shape.getTable().getCellOrNullObject(row, col);
cell.getTextRange().getSubstring(start, length).setSelected(); // does not exist today

…mirroring what already works for ordinary text-bearing shapes via shape.textFrame.textRange.getSubstring(start, length).setSelected() (PowerPointApi 1.5).

Alternatively (coarser but still useful): a cell-level selection primitive such as TableCell.setSelected().

Current behavior

There is no API path that reaches a TextRange (or any selection primitive) for table content:

  1. PowerPoint.TableCell (PowerPointApi 1.8/1.9, and current preview) exposes only whole-cell text (get/set), textRuns, formatting properties, and resize/split — no textFrame, no textRange, no getSubstring, no setSelected.
  2. A table is a GraphicFrame-backed Shape, and accessing shape.textFrame on it throws InvalidArgument (previously reported in When PowerPoint shape is a table, reference to the Shape.TextFrame property throws InvalidArgument error #4380, closed by the stale bot).
  3. The only selection APIs are Presentation.setSelectedSlides, Slide.setSelectedShapes, and TextRange.setSelected — so the finest selection granularity for table content is the entire table shape.

The only way to visually mark sub-cell text today is to edit the document (e.g. rewrite textRuns with a highlight color and revert), which dirties the file, pollutes the undo stack, and is unsafe under co-authoring.

Steps to reproduce

  1. Insert a table on a slide (e.g. via shapes.addTable(2, 2)) and put text in a cell.
  2. Try shape.textFrame.textRange on the table shape → throws InvalidArgument.
  3. Inspect shape.getTable().getCellOrNullObject(0, 0) → no member returns a TextRange or offers selection.
  4. Compare with a plain text box, where textFrame.textRange.getSubstring(2, 5).setSelected() works as expected.

Link to live example(s)

Reproducible in Script Lab with this snippet:

await PowerPoint.run(async (context) => {
  const shapes = context.presentation.getSelectedSlides().getItemAt(0).shapes;

  // Works: sub-range selection in a plain text box (PowerPointApi 1.5)
  const box = shapes.addTextBox("Hello sub-range selection");
  box.textFrame.textRange.getSubstring(6, 9).setSelected();
  await context.sync();

  // No equivalent for a table:
  const tableShape = shapes.addTable(2, 2);
  const cell = tableShape.getTable().getCellOrNullObject(0, 0);
  cell.text = "Hello table cell";
  await context.sync();

  // 1) cell has no textRange/getSubstring/setSelected member
  // 2) tableShape.textFrame.textRange throws InvalidArgument
  // Best available: select the whole table shape
  context.presentation.getSelectedSlides().getItemAt(0).setSelectedShapes([tableShape.id]);
  await context.sync();
});

Context

We build a content-quality add-in (Markup AI) that analyzes presentation text and lets users click a reported issue in the task pane to jump to the exact text in the document. For regular shapes this works well with textFrame.textRange.getSubstring(start, length).setSelected(). For table content — extremely common in business decks — we can only select the whole table shape, so users have to hunt for the flagged text themselves. We deliberately refuse to fake it by temporarily editing highlight formatting, because that modifies the user's file (dirty state, undo pollution, co-authoring conflicts).

PowerPointApi 1.8/1.9 added a rich read/write Table/TableCell surface, so table content is now fully reachable — selection is the one missing piece. TextRange.setSelected already exists; what's missing is a way to obtain a TextRange scoped to a cell.

Useful logs

Metadata

Metadata

Assignees

Labels

Area: PowerPointIssue related to PowerPoint add-ins

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions