Posts: 98
Threads: 46
Joined: Oct 2008
I am having a Excel file having Excel Macro embedded. The simplest way to call that excel macro will to pass it the keyboard shortcut throgh QM. Is it possible to embed that macro in QM as a code piece rather than passing the keys to excel. The Excel Macro contains processes of sorting list, auto fitting etc.
Posts: 12,147
Threads: 143
Joined: Dec 2002
run excel macro from qm without keyboard
Macro
;/exe 1
ExcelSheet es.Init
es.ws.Application.Run("excel macro name")
Posts: 98
Threads: 46
Joined: Oct 2008
The problem is each QM code is run a new excel file is to be created so the macro cannot be called.
Posts: 12,147
Threads: 143
Joined: Dec 2002
You say you can run the excel macro using keyboard shortcut. Then es.ws.Application.Run also should work.
Or you can convert the excel macro to QM. You cannot simply embed it in QM. Some changes needed.
Posts: 98
Threads: 46
Joined: Oct 2008
My mistake earlier I did not told you that a new file will be created so the first one will not work. How can I convert a excel macro to QM. Just provide me an example where the opened excel file columns are selected and format is set to "0.00". VB code this will be :
Range("E:E,G:G,I:I,J:J,K:K,L:L").Select
Range("L1").Activate
Selection.NumberFormat = "#,##0.00"
Posts: 12,147
Threads: 143
Joined: Dec 2002
Macro
;/exe 1
ExcelSheet es.Init
IDispatch a=es.ws.Application
a.Range("E:E,G:G,I:I,J:J,K:K,L:L").Select
a.Range("L1").Activate
a.Selection.NumberFormat = "#,##0.00"
As you see, i only appended a. to every function. Other macros may require some more changes. For example, join lines when split using _.
Posts: 98
Threads: 46
Joined: Oct 2008
Posts: 98
Threads: 46
Joined: Oct 2008
OK one example for sorting also.