Urgent: Embedding an equation from VBA macro

afeder
afeder used Ask the Experts™
on
My macro need to be able to insert an equation (Microsoft Equation 3.0) in the current document.

What I want to do is have the macro take some parameters and then spit out the result as an equation object, complete with calculations and everything. How do I create the equation from my script?

I need the answer before Tuesday.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006
Commented:
Hello afeder,

maybe not what you want to hear but don't think that's possible. you can launch Equation Editor by using the InsertEquation command, but that's only an interactive session. there's no way to generate an equation from a text representation other than using an EQ field, which is quite limited and you can't calculate

but maybe someone comes up with something

HAGD:O)Bruintje

Author

Commented:
The Eq field looks very interesting. I assume a macro can pop up a form and generate the field from the values typed in there? (I'm a complete Word macro newbie)

Just in case anybody can't come up with something else, can you explain how to insert an Eq field from my macro? What command do I use?
Top Expert 2006

Commented:
well you can find more about the EQ field in this search on the mskb

http://search.support.microsoft.com/search/default.aspx?Catalog=LCID%3D1033%26CDID%3DEN-US-KB%26PRODLISTSRC%3DON&Product=&KeywordType=ALL&Titles=false&numDays=&maxResults=50&withinResults=&Queryl=eq+field&Query=eq+field&QuerySource=gsfxSearch_Query

sorry for the long url, and it will return 49 documents not all relevant but it will give more insight in how it can be used but i still think it's a bit difficult to do what you're trying to here

and you can look the eq field up in help

Array switch: \a() Draws a two-dimensional array.
 
Bracket: \b() Brackets a single element.
 
Displace: \d() Moves the next character to the left or right a specified number of points.
 
Fraction: \f(,) Creates a fraction.
 
Integral: \i(,,) Creates an integral, using the specified symbol or default symbol and three elements.
 
List: \l() Groups values in a list, which can then be used as a single element.
 
Overstrike: \o() Prints each successive element on top of the previous one.
 
Radical: \r(,) Draws a radical sign, using one or two elements.
 
Superscript or Subscript: \s() Positions elements as superscripts or subscripts.
 
Box: \x() Draws a border around an element.


these are all fieldcodes for this field and you can add it to the document like other fields maybe it sparks some ideas

:O)Bruintje

Author

Commented:
I figured it out. While the Eq field certainly is limited compared to the Equation Editor it's better than nothing. Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial