MATLAB Answers

How can I use activeX to access Microsoft Excel equation editor from matlab

조회 수: 5(최근 30일)
brolaja
brolaja 22 Mar 2020
댓글: brolaja 22 Mar 2020

  댓글 수: 2

Guillaume
Guillaume 22 Mar 2020
First, you should explain why you want to do that as it's a fairly odd thing to want to do.
Secondly, note that the equation editor was removed from all versions of Office in 2018. What the equation tool now does is insert a textbox shape with the appropriate font into excel. While it can probably be automated from matlab it's not going to be simple.
brolaja
brolaja 22 Mar 2020
I'm working on a symbolic expression calculator to perform some specific functions. I want the user of d app to be able to type mathematical expressions in textbook format

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 22 Mar 2020
" I want the user of d app to be able to type mathematical expressions in textbook format"
I don't believe you're going to achieve that with the equation tool of Excel. For a start it would be very clunky since the user would have to do their inputting in excel. Then, you would be limited in what you can control from matlab. There would be nothing preventing the user for closing excel and you losing your link from matlab.
I've only done limited testing but I don't believe there's an easy way to interact with the equation tool. You could extract the equation after it's been entered by going through the Shapes of the worksheet (assuming you even know which worksheet contains the equation) and extracting the Characters of the TextFrame but you'll have several problems:
  • Even a very basic equation results in invalid characters once extracted in matlab. I've not bothered to try to figure out why
  • Even assuming you could extract the characters correctly, you still have to figure out what the equation is. Bearing in mind that the equation tool use font formatting to render superscripts/subscripts you would have to use characters and format to decode the equation correctly. Twice as much work!
That last point in particular is why I don't think that the equation tool is any good for what you want. Instead I would advise finding some dedicated program (e.g. pick one from this wikipedia list) that can give you either TeX or probably better MathML equations and let your user use that. Converting a MathML equation into a symbolic equation is probably hard enough, I certainly wouldn't try to convert an equation from a tool whose output is not even documented or standardised.

  댓글 수: 0

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Image Analyst
Image Analyst 22 Mar 2020
Usually what I do is to start recording a macro in Excel. Then do what I want to do and then stop recording. Then look in the macro editor to see what commands it did. Then it's just a little bit of translation to go from the Excel VBA code to MATLAB. That's basically how I built my ActiveX Excel_utils class (attached).
So you'd basically do that to find out how the editor gets launched. But then the hard part is how to figure out how to bring that equation back into MATLAB. I have no idea, but good luck though. I agree with Guillaume that it won't be simple. Why can't you just have them type in their equation into MATLAB in a non-wysiwig form?

  댓글 수: 3

brolaja
brolaja 22 Mar 2020
I want them to avoid mistakes when typing mathematical expression
Guillaume
Guillaume 22 Mar 2020
"Usually what I do is to start recording a macro in Excel."
That's what I did before writing my comment to figure out that what excel does is insert a textbox shape. Unfortunately, the actual creation of the formula is not recorded as part of the macro.
brolaja
brolaja 22 Mar 2020
Is there a way I can make them type in textbook format directly into Matlab, I'm currently using UIaxes to the latex interpreted result, is there any edit from d UIaxes end

댓글을 달려면 로그인하십시오.

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by