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

3 ビュー (過去 30 日間)
brolaja
brolaja 2020 年 3 月 22 日
コメント済み: brolaja 2020 年 3 月 22 日
  2 件のコメント
Guillaume
Guillaume 2020 年 3 月 22 日
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 2020 年 3 月 22 日
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 2020 年 3 月 22 日
" 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.

その他の回答 (1 件)

Image Analyst
Image Analyst 2020 年 3 月 22 日
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 件のコメント
Guillaume
Guillaume 2020 年 3 月 22 日
"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 2020 年 3 月 22 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeActiveX についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by