![]() |
|
#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 Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Checking whether the selected lies with in an equation field
|
Bikram | Word VBA | 4 | 03-19-2022 09:54 PM |
Wildcard replace any string in context with a specified string
|
wardw | Word | 7 | 05-07-2018 09:13 AM |
How can I compare a string in a cell to another string?
|
Amitti | Word VBA | 2 | 04-10-2017 07:35 PM |
Way to search for a string in text file, pull out everything until another string?
|
omahadivision | Excel Programming | 12 | 11-23-2013 12:10 PM |
Why copying a paragraph to an equation ends without equation format???
|
Jamal NUMAN | Word | 2 | 04-24-2011 06:18 AM |