How Can I execute a batch file inside a macro?
I'm creating a Run Method (Windows Script Host) to execute the batch file but it doesn't run...
Have anyone already create a macro to run a batch file successfully? Or have a better ideia to run the script of a batch file?
Go to Tools -> Edit Module and then plug the below vbscript/macro:
Set obj = createobject("Wscript.Shell")
obj.Run chr(34) & "Full_Path_To_Your_bat_File" & chr(34), 0
Set obj = Nothing
Then assign this to button or any other object.
Hope this helps.
Thanks Sinan Ozdemir!
But I want to have that code when opening the application (Reload), is that possible?
Opening or Reload? Anyway, Go to Settings -> Document Properties -> Triggers:
You can just when you want to run the macro from Document Event Triggers
And then click on Add Action(s) -> Add -> External -> Run Macro:
Just type the macro name into Macro Name text box:'
This should do it.
Thanks a lot!!!
Sorry for one more question...
In your code is possible to hide the execution window?
Do you mean the cmd window?
Thank you very much!
In your macro, add the below code:
0 is for Error Mode and 1 is for Progress Mode
I think I don't understand very well:
obj.Run chr(34) & "PATH\teste.bat" & chr(34), 0, true
The window it still appear
Thanks very much!
What is the trigger that you are choosing to run the macro?
I just tried it on "OnOpen" and the window didn't appear.
It's strange because when I save the application and I reset the application to aperece window with the execution of the script . If you close the application without saving , and re-do reset , the window no longer appears ... Very strange
What are the module and local security setting in the Edit Module screen?
No problem. You are welcome.
I have the same but sometimes it change to default current local security value (Security Mode)
Retrieving data ...