Microsoft
Software
Hardware
Network
Question : SendKeys in mex file
Hey-- I have an Excel workbook containing macros that needs to be opened and run automatically with a Matlab EXE file. I have the VBA macros in an Auto_Open sub so that they are run immediately upon the opening of the workbook, and I've written Matlab code that automatically opens the Excel workbook. The problem is, when Excel opens, the "Enable or Disable Macros" prompt pops up, and it has to be clicked out of manually in order for the workbook to be opened and the macros to automatically run. The normal way around this is apparently to set the Macro Security level to "Low" which results in the workbook automatically being open with the macros enabled, but due to security settings on my computer I am unable to change the Macro Security level to anything lower than Medium.
In order to programmatically get past the prompt with macros enabled, it occurred to me that all that one would theoretically have to do is press "Tab" to select the "Enable Macros" button, and then "Enter" to get past the prompt, and that this could programmatically be done with the Matlab analog of the VBA "Sendkeys" function. After researching this, I can't find anything in Matlab that replicates the functionality of SendKeys, but it looks like it's actually possible to do in either C or C++, which can then be written into a mex file and executed in Matlab. I'm not really understanding how Sendkeys works in C/C++, though... is it possible to have C/C++ automatically press Tab,Enter in a mex file?
Any help will be greatly appreciated!!
Answer : SendKeys in mex file
SendKeys isn't VBA, it's VBS.
If you need it to work, then write a VBS file with the proper sendkeys stuff in it, save it as a VBS, and then have matlab call that file instead of a C/++ executable.
HTH,
exx
Random Solutions
How do I link combo boxes to select query in a form?
How to run db2 script from control center windows
Cannot pull Data from Oracle using SSIS
Including fields in Filemaker email
XP 10 inbound connection limit question
Retain selected value from dynamic drop down php
Split varchar MS SQL
refresh ribbon any time a worksheet is activated
C#.NET authenticate computer account against Active Directory
Click on an item in a list box and have that value populate a text field