0

以下のコードを使用して、C# 相互運用機能を使用してシェイプ テキストのページ コンテンツを取得しています。

var textRange = shape.TextFrame.TextRange;
var text = textRange.Text;

text には textshape のテキストが含まれます。しかし、すべてのフォーマットがなくなりました。:(

独自のエディターを使用してコンテンツを変更し、変更されたコンテンツを使用して ppt を作成します。

string strToReplace = StripTagsRegex(xmlTempNode.InnerText);
strToReplace = strToReplace.Replace(" ", " ");
shape.TextFrame.TextRange.Text = strToReplace;//load new text to shape

最終出力 (つまり、生成された ppt) で必要なテキストを取得しています。しかし、すべての配置、段落、書式設定がなくなりました。保存する方法はありますか??

立ち寄ってくれてありがとう...!!

4

1 に答える 1

1

PowerPoint 図形内のテキストを置き換えて書式を保持する場合は、PowerPoint 独自の Replace メソッドを使用します。

VBA の場合:

With Shape.TextFrame.TextRange
  .Replace "this text", "with this text"
End With
于 2013-06-28T15:35:18.373 に答える