Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Create a Macro to run a Batch File

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?

Thanks!

1 Solution

Accepted Solutions
sinanozdemir
Valued Contributor III

Re: Create a Macro to run a Batch File

Opening or Reload? Anyway, Go to Settings -> Document Properties -> Triggers:

You can just when you want to run the macro from Document Event Triggers

Capture.PNG

And then click on Add Action(s) -> Add -> External -> Run Macro:

Capture.PNG

Just type the macro name into Macro Name text box:'

Capture.PNG

This should do it.

14 Replies
sinanozdemir
Valued Contributor III

Re: Create a Macro to run a Batch File

Hi,

Go to Tools -> Edit Module and then plug the below vbscript/macro:

Sub Run_BAT

Set obj = createobject("Wscript.Shell")

obj.Run chr(34) & "Full_Path_To_Your_bat_File" & chr(34), 0

Set obj = Nothing

End Sub

Then assign this to button or any other object.

Hope this helps.

Not applicable

Re: Create a Macro to run a Batch File

Thanks Sinan Ozdemir!

But I want to have that code when opening the application (Reload), is that possible?

sinanozdemir
Valued Contributor III

Re: Create a Macro to run a Batch File

Opening or Reload? Anyway, Go to Settings -> Document Properties -> Triggers:

You can just when you want to run the macro from Document Event Triggers

Capture.PNG

And then click on Add Action(s) -> Add -> External -> Run Macro:

Capture.PNG

Just type the macro name into Macro Name text box:'

Capture.PNG

This should do it.

Not applicable

Re: Create a Macro to run a Batch File

Perfect Sinan

Thanks a lot!!!

Not applicable

Re: Create a Macro to run a Batch File

Sorry for one more question...

In your code is possible to hide the execution window?

sinanozdemir
Valued Contributor III

Re: Create a Macro to run a Batch File

Do you mean the cmd window?

sinanozdemir
Valued Contributor III

Re: Create a Macro to run a Batch File

No problem. You are welcome.

Not applicable

Re: Create a Macro to run a Batch File

No,

This window:

Thank you very much!

sinanozdemir
Valued Contributor III

Re: Create a Macro to run a Batch File

In your macro, add the below code:

ActiveDocument.ReloadEx 0,1

0 is for Error Mode and 1 is for Progress Mode

Hope this helps.

Community Browser