[英]How to preserve formatting of textshape format of powerpoint slide using c#
[英]How to format textbox in powerpoint slide
如何格式化文本框? 因為現在它使用的是最后一種格式(沒有粗體和大小20),但我需要有不同格式的標題(粗體和大小30)。 我發現我可以使用richtextbox執行此操作,但我不知道如何在幻燈片中添加richtextbox。
PowerPoint.Shape textBox = activeSlide.Shapes.AddTextbox( Office.MsoTextOrientation.msoTextOrientationHorizontal, 50, 50, 600, 500);
textBox.TextFrame.TextRange.Font.Bold = MsoTriState.msoTrue;
textBox.TextFrame.TextRange.Font.Size = 30;
textBox.TextFrame.TextRange.InsertAfter("This is Title with font size 30 and bold.");
textBox.TextFrame.TextRange.Font.Bold = MsoTriState.msoFalse;
textBox.TextFrame.TextRange.Font.Size = 20;
textBox.TextFrame.TextRange.InsertAfter("This is normal text with font size 20 and no bold.");
看看這個鏈接。 它告訴你如何。
http://msdn.microsoft.com/en-us/library/jj159403(v=office.14).aspx
編輯:所以你問如何添加richtextbox:
Dim rtfBox As RichTextBox = New RichTextBox
rtfBox.Paste()
然后,您可以將rtfBox編輯為您希望的格式。 就那么簡單。 或者您可以創建模板並使用“ 應用模板方法”。
以下是一些可能對您有所幫助的其他鏈接。 他們提到編輯幻燈片並更改字體:
這是一個如何在VBA中執行此操作的示例。 您可以使用不同文本字符串和.Characters的長度來返回您格式化的文本范圍,但是您喜歡不影響其他文本。
Dim oSh As Shape
Dim sBoldText As String
Dim sNotBoldText As String
sBoldText = "This is the title, 30 and bold."
sNotBoldText = " This is the other text, 20 and not bold."
Set oSh = ActivePresentation.Slides(1).Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 500, 100)
oSh.TextFrame.TextRange.Text = sBoldText & sNotBoldText
With oSh.TextFrame.TextRange.Characters(1, Len(sBoldText))
.Font.Bold = True
.Font.Size = 30
End With
With oSh.TextFrame.TextRange.Characters(Len(sBoldText) + 1)
.Font.Bold = False
.Font.Size = 20
End With
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.