【发布时间】:2019-06-14 07:39:12
【问题描述】:
我正在为 PowerPoint 2013 制作插件。我的目标是将我在幻灯片上找到的所有方程式转换为普通文本,以更改这些方程式的字体。
因为当它们是方程式时,它不会让我改变字体。我设法通过遍历文本范围并找到字体名称来找到方程式,他们使用“Cambria Math”。所以我的问题是如何以编程方式将方程式更改为普通文本,就像方程式工具中的按钮一样?似乎出于某种原因,他们从 PowerPoint 中删除了“录制宏”,所以我无法从中获得帮助。
我尝试在 word 中录制宏并做同样的事情,我得到:Selection.OMaths(1).ConvertToMathText,但它似乎不是 PowerPoint 中的 OMaths。
Dim Application As PowerPoint.Application = New PowerPoint.Application
Dim Presentation As PowerPoint.Presentation = Application.ActivePresentation
Dim Windows As PowerPoint.DocumentWindows = Application.Windows
For Each Slide As PowerPoint.Slide In Presentation.Slides
For Each Shape As PowerPoint.Shape In Slide.Shapes
For Each Paragraph As PowerPoint.TextRange In Shape.TextFrame.TextRange
For Each Line As PowerPoint.TextRange In Paragraph.Lines
If Line.Font.Name = "Cambria Math" Then
With Line.Font
.Name = "Calibri"
.Bold = True
End With
ElseIf Line.Font.Name = "Calibri" Then
With Line.Font
.Name = "Palatino"
End With
End If
Next Line
Next Paragraph
Next Shape
Next Slide
End Sub
这里的其他文字正常更改,但带有“Math Cambria”字体的方程式没有变化。
我还尝试进行选择,然后使用 OMaths 进行选择,例如在 Word Vsto 中,但是,似乎 OMaths 不是 PowerPoint 的一部分。下一个代码实际上应该将其更改为方程式,但我想如果它有效,可能会找到一种方法来扭转它。
For Each Window As PowerPoint.DocumentWindow In Windows
Selection.OMaths(1).ConvertToMathText
Next Window
【问题讨论】:
-
@aduguid 我编辑了这个问题,希望它更清楚。
标签: vba vsto powerpoint powerpoint-2013