Excel/Word Equations using oMath.BuildUp method?

前提是你 提交于 2019-11-30 15:50:52

AFAIK it just doesn't work that way. You could do your own math autocorrect substitution, e.g. using something based on this:

Function mathSubstitute(s As String) As String
Const bslash As String = "\"
Dim a() As String
Dim sout As String
Dim i As Integer
Dim j As Integer
Dim sac As String
sout = ""
If s <> "" Then
  a = Split(s, bslash)
  sout = a(LBound(a))
  For i = LBound(a) + 1 To UBound(a)
    Debug.Print a(i)
    For j = 1 To Len(a(i))
      On Error Resume Next
      sac = Application.OMathAutoCorrect.Entries(bslash & Left(a(i), j)).Value
      If Err.Number = 0 Then
        sout = sout & sac & Mid(a(i), j + 1)
        Exit For
      Else
        sac = ""
        Err.Clear
      End If
    Next
    If sac = "" Then sout = sout & bslash & a(i)
    Debug.Print sout
  Next
End If
On Error GoTo 0
mathSubstitute = sout
End Function

and change your code to

objRange.Text = mathSubstitute("Celsius = \sqrt(x+y) + sin(5/9 \times (Fahrenheit – 23 (\delta)^2))")

AFAICS the use of "\" to escape special characters such as [ still works correctly.

Goura

Repeat it twice, it will solve your problem.

objEq.BuildUp
objEq.BuildUp
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!