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 に答える