Issue: Microsoft PowerPoint API returns empty placeholder text after update [2409]
I’m using the Microsoft PowerPoint JavaScript API to generate slides from slide master, where the shapes are created within layouts using GeometricShape. A placeholder text is assigned to each shape to help identify them, so they can later be populated with the correct data.
This code functioned correctly with an earlier version of Office (Version 2409, Build 18025.20160). However, since a recent Office update, it now returns an empty string for the placeholder text, despite previously working without any issues.
Here’s the code that was used to access slide masters, layouts, and shapes within a PowerPoint presentation:
$("#run").on("click", run);
async function run() {
await PowerPoint.run(async (context) => {
context.presentation.load("slideMasters");
await context.sync();
const slideMasters = context.presentation.slideMasters;
const validSlideMasters = await getAllSlideMasterInList(slideMasters);
for (const master of validSlideMasters) {
master.load();
await context.sync();
const validLayoutArray = await getValidSlideLayoutsFromSlideMaster(master);
for (const layout of validLayoutArray) {
await getSlideLayoutPlaceholderText(layout);
}
}
});
}
async function getAllSlideMasterInList(slideMasterCollection) {
const slideMasterList = [];
const context = slideMasterCollection.context;
slideMasterCollection.load("items");
await context.sync();
slideMasterCollection.items.forEach((slideMaster) => {
slideMasterList.push(slideMaster);
});
return slideMasterList;
}
async function getValidSlideLayoutsFromSlideMaster(slideMaster) {
const slideLayoutArray = [];
const context = slideMaster.context;
slideMaster.load("layouts");
slideMaster.load("name");
await context.sync();
const slideLayouts = slideMaster.layouts;
slideLayouts.load("items");
await context.sync();
slideLayouts.items.forEach((slideLayout) => {
if (slideLayout.name.startsWith("TestLayoutName")) {
slideLayoutArray.push(slideLayout);
}
});
return slideLayoutArray;
}
async function getSlideLayoutPlaceholderText(slideLayout) {
const context = slideLayout.context;
slideLayout.load("shapes");
slideLayout.load("name");
await context.sync();
const shapes = slideLayout.shapes;
shapes.load("items");
await context.sync();
for (const shape of shapes.items) {
if (shape.type === "GeometricShape") {
shape.load();
shape.textFrame.load();
await context.sync();
shape.textFrame.textRange.load(["text"]);
await context.sync();
console.log("Slide Layout Name:", slideLayout.name);
console.log("Shape text", shape.textFrame.textRange.text);
}
}
}
Here is the sample slide master view: (https://i.sstatic.net/9nqllwuK.png)
Issue Observed: Previously, shape.textFrame.textRange.text would return the text of placeholders and shapes, as expected. However, since the recent update, shape.textFrame.textRange.text is now returning an empty string for placeholders that previously had text.
Troubleshooting Attempts:
- Verified that placeholders in the PowerPoint presentation have text.
- Checked that the textFrame and textRange objects are properly loaded and synced.
- Confirmed that no errors are thrown by the API.
Environment:
- Previous Office Version: Version 2409 (Build 18025.20160) - working as expected
- Current Office Version: Version 2410 (Build 18129.20116) - issue observed
Question: Has anyone experienced similar issues with placeholder text retrieval after a recent Office update? Is there any workaround, or has something changed in the API that might be causing this behavior? Any insights would be appreciated.