是否有一种方法可以在PowerPoint VSTO中创建样式来格式化文本,类似于Word文档所能做到的:
// document is of type Microsoft.Office.Interop.Word.Document
Style sectionHeadingExt = document.Styles.Add("myStyle");
sectionHeadingExt.set_BaseStyle(SectionHeadingInt);
sectionHeadingExt.Font.Size = 14;
sectionHeadingExt.Font.Color = WdColor.wdColorBlack;
sectionHeadingExt.Font.Bold = (int)MsoTriState.msoFalse;
sectionHeadingExt.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceMultiple;
sectionHeadingExt.ParagraphFormat.LineSpacing = _application.LinesToPoints((float)1.11);
sectionHeadingExt.ParagraphFormat.SpaceBefore = 0;
sectionHeadingExt.ParagraphFormat.SpaceAfter = 0;我需要创建一个自定义带状选项卡,在那里添加一个按钮,当单击该按钮时,我需要相应地格式化所选段落:
GetCurrentParagraph().set_Style("myStyle");我是在Word AddIn中这样做的,但是用PowerPoint可以吗?另外,我看不到样式/在PowerPoint中更改样式选项(在Word中它们出现在Home选项卡上)。
发布于 2012-01-23 15:24:27
Word有一个样式特性;PowerPoint没有,所以不可能像在Word中那样这样做。
您可能需要编写代码来获取和存储各种属性,这些属性确定文本的外观(字体名称、大小、粗体/斜体、行距、段落间距、颜色等),以及将存储的属性应用于另一段文本的代码。
(这是你的后续评论).是。
Dim oRng As TextRange
' Is text selected? If so, work with it, else quit:
With ActiveWindow.Selection
If .Type = ppSelectionText Then
Set oRng = .TextRange
Else
Exit Sub
End If
End With ' Selection
With oRng
With .Font
.Bold = True
.Size = 24 ' point
' and so on
End With
End With ' oRnghttps://stackoverflow.com/questions/8973575
复制相似问题