View Single Post
 
Old 10-19-2019, 06:35 AM
George Keeling George Keeling is offline Windows 10 Office 2019
Novice
 
Join Date: Oct 2019
Posts: 4
George Keeling is on a distinguished road
Default Another solution

Merci jpl. Peut-être que cela vous rajeunira!
Code:
Sub ExampleWriteExpression()
    'insertion point should be in equation. Metric + inverse metric inserted
    Dim Equation As OMath
    Dim MathTerm As OMathFunction

    If Selection.OMaths.Count <> 1 Then ExpanderFatalError ("Cursor must be in an equation.")
    Set Equation = Selection.OMaths(1)
    Set MathTerm = Equation.Functions.Add(Selection.Range, wdOMathFunctionScrSub)
    MathTerm.ScrSub.E.Range = "g"
    MathTerm.ScrSub.Sub.Range = ChrW(&H3BC) & ChrW(&H3BD)
 
    Selection.TypeText ("+")
 
'    Set MathTerm = Equation.Functions.Add(Selection.Range, wdOMathFunctionText) still gets error

    Set MathTerm = Equation.Functions.Add(Selection.Range, wdOMathFunctionScrSup)
    MathTerm.ScrSup.E.Range = "g"
    MathTerm.ScrSup.Sup.Range = ChrW(&H3BC) & ChrW(&H3BD)
End Sub
I believe that the Add method is defective when type=wdOMathFunctionText is used.
The above is another solution. But it does not solve the problem of aligning the selection in the equation. I have documented the problem more fully here and presented some code for expanding the Christoffel symbol.
Reply With Quote