Prev: combining cells
Next: TooltipString Value
From: Anonymous on 10 Apr 2010 17:39 Hi, I tried to create a code in Matlab which runs a macro I've created in Excel. The macro ([i]vw_check[/i]) should run in file [b]118.xls[/b]. The problem is that I couldn't save/made the macro in [b]118.xls[/b], because [b]118.xls[/b] is one of a bunch xls-files created by matlab. So I've saved/made the macro in an empty xls-file [b]Excelmacros.xls[/b]. My matlab code is: winopen('C:\Excelmacros.xls'); Excel=actxserver('Excel.Application'); set(Excel, 'Visible', 1); Excel.Workbooks.Open(C:\118.xls); [i]% Now I can see in 118.xls the macro I'd like to run and it's called [b]Excelmacros.xls!vw_check[/b] (because the macro is saved in Excelmacros.xls)[/i] Excel.ExecuteExcel4Macro('!Excelmacros.xls!vw_check()'); I think the problem is that matlab couldn't cope with the [b]![/b] between 'Excelmacros.xls' and 'vw_check' in the last line. To be sure, I have changed my matlab code for the situation that I had made the macro in [b]118.xls[/b], and therefore the last line of my matlab code would be: Excel.ExecuteExcel4Macro('!vw_check()'); And that works! So, I'm 99% sure that the problem is indeed the [b]![/b]. I don't have any idea how to solve this... The possibility to make the macro in 118.xls isn't a real solution because 118.xls is automatically made bij matlab. I'll hope someone could fix this or help me with a solution. All ideas and help appreciated!! Tnx!
From: james bejon on 11 Apr 2010 04:26 I'm not totally sure what ExecuteExcel4Macro does. But if you just want to run a macro, Application.Run should do the job. The syntax is then 'BookName'!MacroName, being careful to include the quotes. So, Excel.Run(['''', '118.xls', '''!vw_check']); or whatever they happen to be called works for me.
From: Anonymous on 11 Apr 2010 06:02 "james bejon" <jamesbejon(a)yahoo.co.uk> wrote in message <hps12q$cph$1(a)fred.mathworks.com>... > I'm not totally sure what ExecuteExcel4Macro does. But if you just want to run a macro, Application.Run should do the job. The syntax is then 'BookName'!MacroName, being careful to include the quotes. So, > > Excel.Run(['''', '118.xls', '''!vw_check']); > > or whatever they happen to be called works for me. Oh yeah!! That's working :D I also don't know the difference between ExecuteExcel4Macro and Excel.Run, but Excel.Run works fine! Muchos gracias!
|
Pages: 1 Prev: combining cells Next: TooltipString Value |