0

[stripped whining]

My current issue is that I am trying to get a list of shapes, and check the tags for each shape and if I find a specific tag, I do something with it.

This worked at one time, and I am not sure what changed to make this no longer work.

What is happening now is that I am getting the following error message while trying to read tag.value: RichApi.Error: GeneralException.

I have tried multiple different ways to get this data (see below), so the error has been different places. Right now it is showing that the offending statement is var tag = tags.getItem("mc-accessToken");, but earlier it was at (!tag.isNullObject) and then await this.replaceExistingDiagram(tag.value); (on tag.value)

Can someone please direct me to a resource that can help!

My original code was as follows:

await PowerPoint.run(async (context) => {
      const presentation = context.presentation;
      const slides = presentation.slides.load("items");
      await context.sync();

      for(let slideIndex = 0; slideIndex < slides.items.length; slideIndex++) {
        const slide = slides.items[slideIndex];
        const shapes = slide.shapes.load("items");
        
        await context.sync();

        for (let shapeIndex = 0; shapeIndex < shapes.items.length; shapeIndex++) {
          const shape = shapes.items[shapeIndex];
          const tag = shape.tags.getItemOrNullObject(C.TokenSettingName);
          if (!tag.isNullObject) {
            shape.delete();
            await this.replaceExistingDiagram(tag.value);
          }
        }
      }
    });

I have made different changes to try and make sure that I am loading the properties I need My current iteration of code looks like this (only showing changes):

        const shapes = slide.shapes.load('items');
        await context.sync();

       for ... {
          const shape = shapes.items[shapeIndex];
          shape.tags.load("key, value");
          await context.sync();
          
          ...
        }

I have also tried:

  • const shapes = slide.shapes.load('items, isNullObject');
  • const tag = shape.tags.getItem(C.TokenSettingName);
  • shape.load('tags');
  • shape.load('tags');
  • const tag = shape.tags.getItem(C.TokenSettingName); tag.load('value');
  • shapes.load("tags/key, tags/value");

( I just found this: shapes.load("items/$none");, would I need to do something like shapes.load("items/tags");?)

6
  • Your 1st point isn't really suitable for Stack. Please go to load(). If you don't find it useful, scroll to the bottom of the page and create and issue with the This page button. Commented Nov 28, 2023 at 20:49
  • For your 2nd point, please reproduce the issue in Script Lab. Use the code that you say used to work and has stopped working. Then export the code as a gist from Script Lab and provide a URL to the gist. Commented Nov 28, 2023 at 20:58
  • @RickKirkham - link to documentation gives a 404 Commented Nov 28, 2023 at 21:09
  • Im not sure what code worked. At this point I just want to get the code to work at all - At this point I am looking to understand what is the right way to get the tags for a shape Commented Nov 28, 2023 at 21:10
  • Try learn.microsoft.com/en-us/office/dev/add-ins/develop/… Commented Nov 29, 2023 at 0:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.