簡體   English   中英

如何使用C#保留PowerPoint幻燈片的textshape格式的格式

[英]How to preserve formatting of textshape format of powerpoint slide using c#

我正在使用c#interop使用以下代碼獲取形狀文本的頁面內容:

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

其中文本包含textshape的文本。 但是所有格式都不見了。 :(

我們使用自己的編輯器修改內容,並使用更改后的內容創建ppt:

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

我在最終輸出中得到了所需的文本(即生成的ppt)。但是所有對齊方式,段落,格式都消失了。 有什么辦法可以保存它?

感謝您的光臨... !!

如果要替換PowerPoint形狀中的文本並保留格式,請使用PowerPoint自己的Replace方法。

在VBA中:

With Shape.TextFrame.TextRange
  .Replace "this text", "with this text"
End With

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM