modify built-in matlab mex file
Posted on 2010-08-25
Hey-- I am attempting to automatically open an excel workbook with Matlab code that has macros running automatically when it opens via an Auto_Open sub in VBA. When I use:
exlWkbk = Excel1.Workbooks;
exlFile = exlWkbk.Open('filename.xls')
Excel opens with the macros enabled, but the macros do not automatically run upon opening despite being in the Auto_Open sub, and I am also unable to change the Macro Security level on my computer. I noticed that if I use the Matlab winopen function to open the workbook, however, it prompts me to click disable or enable macros, and when I click enable, it opens and the Auto_Open macros do automatically run.
My idea was to open it with winopen and then write code to programmatically select enable from the prompt, which I've been able to do via Sendkeys code in VB which I've saved as a .vbs file... I am able to call it in Matlab and it does successfully click enable and get through the prompt. The problem is, I have to call winopen to get to the prompt and then call vbs to get through it, and winopen does not stop executing until the prompt is already clicked out of... Since Matlab is open-source my new idea was to modify winopen so that it just stops executing right when it gets to the prompt so taht the vbs file can then be executed to do it, but while winopen is an open-source m-file, it seems to use a helper win_open_mex function that is a Matlab mex file. I figured I could modify the C code in the mex file and go from there, but I'm unable to access the mex code... I open it in Notepad, WordPad, Word, etc and it's all just giberish...
Is there any way to either access the win_open_mex code to modify it, or to approach the whole thing any other way that may work better and be easier??
I really appreciate your help.