Permission denied when accessing name in items powerpoint add-in office js api

14 views Asked by At

I'm creating an add-in for powerpoint and i want to change the text of a specefic textFrame which i can only identify with the attribute name.The code works very well with the online version of office but it shows permission denied for the attribute name and others .this is what i'm having at the console :

[object Object]: {_className: "Shape", _context: Object, _I: "2#{00000000-0000-0000-0000-000000000000}", _isNull: false, _navigationPropertyNames: Array...}

_className: "Shape"

_context: Object

_I: "2#{00000000-0000-0000-0000-000000000000}"

_isNull: false

_navigationPropertyNames: Array

_objectPath: Object

_scalarPropertyNames: Array

_scalarPropertyOriginalNames: Array

_scalarPropertyUpdateable: Array

context: Object

fill: Object

height:

id: "2#{00000000-0000-0000-0000-000000000000}"

isNull: false

isNullObject: false

left:

lineFormat: Object

m_context: Object

m_contextBase: Object

m_isNull: false

m_objectPath: Object

name:

tags: Object

textFrame: Object

top:

type:

width:

proto: Object

and this is my code :

function getSpecficElement(name) {

        return new Promise((resolve, reject) => {

            PowerPoint.run(async function (context) {

                let index = 1;

                let slide = context.presentation.slides.getItemAt(index - 1);

                let shapes = slide.shapes;

                shapes.load();

                await context.sync();

                console.log(Office.context.diagnostics.platform);

                console.log(Office.context.diagnostics.version);

                for (let i in shapes.items) {

                    let item = shapes.items[i];

                    item.load();

                    await context.sync();

                    if (item.name.toLowerCase() === name.toLowerCase()) {

                        resolve(item);

                    }

                }

                reject(new Error("Element does not exist"))

            });

        });

    }

I tried to add many .load() and context.sync() but instead it shows general exception.

0

There are 0 answers