Question

doc = app.Documents.Add(fileInfo[i].FullName);
Vis.Shapes shapes = doc.Pages[1].Shapes;
for (int j = 1; j <= shapes.Count; j++)
{
    if (shapes[j].Text.StartsWith("getSomeThing"))
    {
         shapes[j].Text = "doSomething()";                            
    }
}

shapes[j].Text = "doSomething()"; this line will cause an exception, how to fix it?

It causes a COMException.

Exception message is "The requested operation is disabled".

ErrorCode = -2032465766

Was it helpful?

Solution

Maybe there is some shape with lock on text edit. You can remove that protection:

shape.get_CellsSRC((short)VisSectionIndices.visSectionObject,
                   (short)VisRowIndice‌​s.visRowLock,
                   (short)VisCellIndices.visLockTextEdit).FormulaU = "0"; //to remove protection

And it is better to "remember" old value and set it back after yours edits.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top