1
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()";                            
    }
}

形状[j].Text = "doSomething()"; 这条线会导致异常,如何解决?

它会导致COMException

异常消息是“请求的操作已禁用”。

错误代码 = -2032465766

4

1 回答 1

1

也许有一些形状锁定文本编辑。您可以删除该保护:

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

最好“记住”旧值并在您的编辑后将其设置回来。

于 2012-12-27T08:07:00.877 回答