Hi All,
Is it possible to call Excel from another program to pass it a string and get back results?
We have some VBA code in PowerPoint and Word. It accepts some user inputs in the form of an answer to a math problem.
Rather than trying to parse the code in the VBA for those programs (or store some number of “acceptable” answers since you just never know what alternative, but correct, form a user might try) and get back a result (including an error), we thought it might be easier to let Excel figure it out, as if the string had been entered into a cell as a formula (or a constant), and then get back the result of that formula.
For example, if the answer to a problem was 2, the input could be just 2, or sqrt(4), or any other expression that reduces to 2. If the user put in srqt(4), that should result in a #ERROR of some kind (probably a #NAME). In any case, if Excel comes back with 2, then whatever form the user originally put in is ok. If the answer comes back as anything else, then the user’s input is either mathematically wrong (eg, Excel comes back with 2.5) or is syntactically wrong (srqt instead of sqrt).
For trig questions, this could get tricky. For example, sin(60 deg) = sqrt(3)/2. The user might input that and it would be exactly right. Problem with above is that Excel would return 0.866… Not quite sure how to deal with that yet.
Any suggestions for an alternative approach would be great. Just trying to avoid from storing strings that we think represent all possibilities of a correct answer, since history proves we can never think of all correct forms.
TIA
Fred