Open ghaskins99 opened 1 year ago
Thanks for reporting this issue.
It has been put on our backlog<Bug#8369126> for internal track. We will keep track of this issue and let you know if there are any updates.
I am facing the same issue for same kind of problem. We are also developing an add-in with similar functionality and my issue is not with replacing the image, which I can achieve using getSelectedShapes and then replacing it, but adding a second image with tags , while an image with custom tags is already selected on some slide. So if an image is already selected in the slide, and Then If I try to add an image to the slide using setSelectedDataAsync it throws error code 2001, I am hoping this would be resolved with this same bug?
if it helps, i implemented this alternative code to reset the current slide selection:
const resetPowerPointSlideItemsSelection = async (): Promise<void> => {
const currentSlideId: number = await new Promise<number>((resolve, reject) => {
Office.context.document.getSelectedDataAsync<PowerPoint.Presentation>(
Office.CoercionType.SlideRange,
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
reject(asyncResult);
} else {
resolve(asyncResult.value.slides[0].id);
}
}
);
});
return new Promise<void>((resolve, reject) => {
Office.context.document.goToByIdAsync(currentSlideId, Office.GoToType.Slide, function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
reject(asyncResult);
} else {
resolve();
}
});
});
};
Your Environment
Expected behavior
calling
setSelectedDataAsync
should not fail if the user has selected something; or there should be an alternative which inserts rather than attempting to change the selection assetSelectedDataAsync
seems to be currently the only way to insert an image into PPTcalling
slide.setSelectedShapes([]);
should clear the selectionCurrent behavior
calling
setSelectedDataAsync
throwsOSF.DDA.Error 2001
calling
slide.setSelectedShapes([]);
does nothing and appears to halt thePowerPoint.run
callback, ie. no other statements after that appear to run, but there is no error message.Steps to reproduce
setSelectedDataAsync
to insert base64 image data with coercion type Image, ex.:this would not be an issue if we could programatically unselect, but for that:
use code such as: (logging added for purposes of this issue)
Context
Our addin allows users to insert a visual representation of a live file as an image into their PPT slide. If the backing file changes we would like to allow the users to update the image representation by selecting the image and clicking "update" from the task pane addin, which renders the latest version as an image, places itself where the old image was, and deletes the old image (since as far as I can tell we cannot update the existing image's contents).
Being unable to
setSelectedDataAsync
while an image is selected breaks this functionality since the image must be selected in the first place in order to have the option to update it appear in the task pane, which also shows other relevant information about the file).We also believe this (the
setSelectedDataAsync
error) is a regression since I am somewhere between 75-99% sure that this update flow (ie. inserting an image while one is selected) was verified to be working in the browser before. The error is only thrown from Web, not desktop.We could programatically deselect the image right before inserting (n.b., works in desktop, though is not needed there anyway), but using
setSelectedShapes([])
does nothing in browser (see #3102, #3083).Added the information about deselecting again in this issue since it provides context to why throwing an error on
setSelectedDataAsync
is not useful. Also highlighting that there are no errors logged when setting the selection to nothing fails, and it seems to cause thePowerPoint.run
promise to never resolve.Useful logs
Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.