[英]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.