How can I use activeX to access Microsoft Excel equation editor from matlab
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
brolaja
el 22 de Mzo. de 2020
Comentada: brolaja
el 22 de Mzo. de 2020
2 comentarios
Guillaume
el 22 de Mzo. de 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.
Respuesta aceptada
Guillaume
el 22 de Mzo. de 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 comentarios
Más respuestas (1)
Image Analyst
el 22 de Mzo. de 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 comentarios
Guillaume
el 22 de Mzo. de 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.
Ver también
Categorías
Más información sobre ActiveX en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!