Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I need to find a way to start QV, reload, select the current month and year and then print a report.
Is there an easy way to do that? Reload is not the problem, but how can I select fields and print reports?
Hope someone can help me.
Best regards
Hi!
I had a similar issue. I solved it as follows:
First, I created a .bat file that opens the QlikView file and passes a variable:
"C:\Program Files\QlikView\QV.exe" /vmRunMacro=1 "C:\QV\MacroFromCMD.qvw"
that line opens MacroFromCMD.qvw and sets the variable vmRunMacro (that must be created in the QV file) to value 1.
Secondly, I created an action "On Open" (Settings >> Document Properties >> Triggers >> OnOpen >> Edit Actions). It is a "Run Macro" action that runs the following code:
Sub Macro
msgbox("Entered in macro")
RunMacro = CInt(ActiveDocument.Variables("mRunMacro").GetContent.String)
if RunMacro = 1 then
msgbox("Macro executed")
'YOUR CODE HERE
ActiveDocument.Variables("mRunMacro").SetContent 0, false
ActiveDocument.Save
ActiveDocument.GetApplication.Quit
else
msgbox("Macro NOT executed")
end if
end subBassically, if the variable "mRunMacro" is 1, macro is executed. Else, it does nothing. If macro is executed, I set the variable "mRunMacro" to 0 (so I can open the QV by myself without macro execution), I save the QV file (because at least I changed tha variable value so document save is needed) and finally I close the app (because if macro is executed it is launched by a .bat file and I want that the app closes on finish).
Tha last thing you need is to add your own code. It may be something like
ActiveDocument.Fields("Month").Select Month(now)
ActiveDocument.Fields("Year").Select Year(now)
ActiveDocument.PrintReport "[YOUR REPORT ID]"I attach a QV and file so you can test but you have to create your own bat file following the instrucions above.
For more about macros I refer you to the documentation (QlikView Automation Reference.pdf and APIguide.qvw)
Bests,
Jaime.
The easy way is to use NPrinting
I know, unfortunately we don't have NPrinting yet.
So I have to find a way by using batch/macros.
Hi!
I had a similar issue. I solved it as follows:
First, I created a .bat file that opens the QlikView file and passes a variable:
"C:\Program Files\QlikView\QV.exe" /vmRunMacro=1 "C:\QV\MacroFromCMD.qvw"
that line opens MacroFromCMD.qvw and sets the variable vmRunMacro (that must be created in the QV file) to value 1.
Secondly, I created an action "On Open" (Settings >> Document Properties >> Triggers >> OnOpen >> Edit Actions). It is a "Run Macro" action that runs the following code:
Sub Macro
msgbox("Entered in macro")
RunMacro = CInt(ActiveDocument.Variables("mRunMacro").GetContent.String)
if RunMacro = 1 then
msgbox("Macro executed")
'YOUR CODE HERE
ActiveDocument.Variables("mRunMacro").SetContent 0, false
ActiveDocument.Save
ActiveDocument.GetApplication.Quit
else
msgbox("Macro NOT executed")
end if
end subBassically, if the variable "mRunMacro" is 1, macro is executed. Else, it does nothing. If macro is executed, I set the variable "mRunMacro" to 0 (so I can open the QV by myself without macro execution), I save the QV file (because at least I changed tha variable value so document save is needed) and finally I close the app (because if macro is executed it is launched by a .bat file and I want that the app closes on finish).
Tha last thing you need is to add your own code. It may be something like
ActiveDocument.Fields("Month").Select Month(now)
ActiveDocument.Fields("Year").Select Year(now)
ActiveDocument.PrintReport "[YOUR REPORT ID]"I attach a QV and file so you can test but you have to create your own bat file following the instrucions above.
For more about macros I refer you to the documentation (QlikView Automation Reference.pdf and APIguide.qvw)
Bests,
Jaime.
Thank you for your detailed answer!
I just solved it a bit different using this:
and the apiguide.
I will mark your answer as solution.