![]() |
|
#1
|
|||
|
|||
![]()
If I select a string such as
\(b = CA = \sqrt{(x_3 - x_1)^2 + (y_3 - y_1)^2}\) I can turn it into a math equation by selecting Insert/Equation/Latex/convert/all professional it then looks like attached image. Can I do this by VBA, by selecting the text then executing the VBA? |
#2
|
||||
|
||||
![]()
Try:
Code:
Sub ConvertEquation() Application.ScreenUpdating = False Dim Rng As Range, objEqn As OMath, Correction As OMathAutoCorrectEntry Application.OMathAutoCorrect.UseOutsideOMath = True Set Rng = Selection.Range: If Rng.End = Rng.Paragraphs.First.Range.End Then Rng.End = Rng.End - 1 For Each Correction In Application.OMathAutoCorrect.Entries If InStr(Rng.Text, Correction.Name) > 0 Then Rng.Text = Replace(Rng.Text, Correction.Name, Correction.Value) Next Rng.OMaths.Add(Rng).OMaths(1).BuildUp Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Thank you very much Macropod, it solves my problem.
|
![]() |
Tags |
math equation |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Bikram | Word VBA | 4 | 03-19-2022 09:54 PM |
![]() |
wardw | Word | 7 | 05-07-2018 09:13 AM |
![]() |
Amitti | Word VBA | 2 | 04-10-2017 07:35 PM |
![]() |
omahadivision | Excel Programming | 12 | 11-23-2013 12:10 PM |
![]() |
Jamal NUMAN | Word | 2 | 04-24-2011 06:18 AM |