我在VBA Excel中编写一个宏,用于对word文档进行一些数据处理。在此期间,我已将整个文档的字体名称更改为Times New Roman。但我不希望对文档中的“公式编辑器”框应用相同的更改,因为它们的字体是“Cambria Math”。将字体更改为Times New Roman会导致数据模糊不清。
答案 0 :(得分:0)
在2007年之后,方程式对象发生了变化。在2007年之前,您可以通过声明Field
个对象来处理这些对象。例如
<强> UNTESTED 强>
Sub Sample()
Dim fldEqn As Field
For Each fldEqn In ActiveDocument.Fields
If fldEqn.Type = wdFieldEmbed Then
If InStr(1, fldEqn, "Equation.3") Then
With fldEqn.Result.Font
'
'~~> Rest of the code
'
End With
End If
End If
Next oField
End Sub
要使用2007年以后的Equation Objects
,您必须使用OMaths集合。
您可以使用此代码更改所有等式的字体
Sub Sample()
Dim eqns As OMath
For Each eqns In ActiveDocument.OMaths
With eqns.Range.Font
'
'~~> Rest of the code
'
End With
Next
End Sub