0

I'm following the methods of this Mathworks post (but using Octave 6.2.0 instead of Matlab)

https://www.mathworks.com/matlabcentral/answers/100938-how-can-i-run-an-excel-macro-from-matlab

to open an Excel file (Office 365 version) and execute a macro. It works very well to a point (i.e. on a test Excel file containing a test macro). However, in practice I'm using the xlsopen(...) , oct2xls(...), and xlsclose(...) functions in Octave to create the Excel file I ultimately want to use, so I think I either have to...

(a) use Octave to create an Excel file containing a VBA macro, or

(b) adapt one of the options in the Mathworks post to be able to run a macro from the 'PERSONAL.xlsb' workbook instead. I've tried changing the 'Macro1' name to PERSONAL.xlsb!Macro1 (with 'Macro1' coded into a module within the personal workbook) but this does not execute the macro and gives the following error in Octave:

error: com_invoke: property/method invocation on the COM object failed with error `0x80020009' - Exception occurred.

Invoking the macro coded into the personal workbook directly from the active workbook is successful (even if it's a different workbook), I just need Octave to do this step.

Are either of these possible to do, or is there another alternative? Thanks in advance.

smcmi
  • 106
  • 8
  • are you using the `io` package, or are you using the `windows` package like [here](https://stackoverflow.com/q/66250108/4183191)? – Tasos Papastylianou Apr 30 '21 at 13:33
  • Both, actually. I'm using the `io` package to create an Excel file, and the `windows` package to open the (test) Excel file and run the (test) macro. I haven't figured out a way to run a macro in the Excel file created during the process involving the `io` package, which prompted me to post my question. I'm wondering if I should call the 'PERSONAL.xlsb' workbook instead of the `io` -created workbook when using the `actxserver` function and try to work the changes into the created file from there instead? – smcmi Apr 30 '21 at 14:34
  • @TasosPapastylianou, I forgot to tag you, sorry. – smcmi Apr 30 '21 at 14:56
  • I haven't followed 100% what you said, but if what you're asking is if you can mix the two interfaces, then I'm guessing the answer is that's probably not a good idea. – Tasos Papastylianou Apr 30 '21 at 20:18

0 Answers0