Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Vbs - passing parameters to opendoc or opendocex

Hi everyone,

thanks for all your solutions and good topics of this community.

I have a issue with automating the reloading of qvw with vbs. Indeed, I would like to reload a bunch of apps with a batch script.

Thus, I first used the qv.exe command line with /r and /l arguments but I faced an issue with the progress window that does not automatically close.

So I then found the vbs solution, using the opendocex function which allow a "progress mode" and avoid this progress window. This nicely works, except that I can not find out how to pass parameters to this method (same as /v argument with the qv.exe command line).

I searched my friend google but have not found out the answer. Any idea ?

Thanks by advance for you help.

Romain

Tags (3)
1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: Vbs - passing parameters to opendoc or opendocex

This worked:

Option Explicit

Dim QA, QD, apppath, param1, newdoc  

apppath = "C:\test.qvw"

param1 = inputBox("param: ")

set QA = CreateObject("QlikTech.QlikView")

set QD = QA.ActiveDocument.GetApplication

set newdoc = QD.OpenDoc(apppath, "","")

      

newdoc.Variables("matable").SetContent param1, true

      

newdoc.ReloadEx 0,1

newdoc.save

newdoc.CloseDoc

QD.Quit   

- Marcus

7 Replies
multiview
Contributor II

Re: Vbs - passing parameters to opendoc or opendocex

1 - Using Publisher

In QlikView QMC-> Users-> Supporting Tasks-> External commands. You could run external commands and pass parameters the same way you schedule a Windows Scheduled task.

2 - ShellExecute command :

- Make sure that you have checked on 'close when finished' on Script Execution Progress window.

- Also you could use window paramter to hide QV to be displayed while reloading ,     Example : http://ss64.com/vb/shellexecute.html

I hope this helps!

MultiView

Highlighted
MVP & Luminary
MVP & Luminary

Re: Vbs - passing parameters to opendoc or opendocex

You could the apps treat as object and set hereby any variables you want:

set App = ActiveDocument.GetApplication

set newdoc = App.OpenDoc (Path & Area & arr(i_app),"","")

newdoc.Variables("text_update").SetContent M_all, true

- Marcus

Not applicable

Re: Vbs - passing parameters to opendoc or opendocex

Thank you Multiview and Marcus.

I tried the "object" solution, but unfortunately I got an error :

"Required Object: 'Variables(...)'"

?

oO

MVP & Luminary
MVP & Luminary

Re: Vbs - passing parameters to opendoc or opendocex

Your variable is already exists in the called app? Perhaps there is a little error in the syntax ... post your code.

- Marcus

Not applicable

Re: Vbs - passing parameters to opendoc or opendocex

Thank you very much for your assistance Marcus.

This is my code:

Option Explicit

Dim QA, QD, apppath, param1

 

apppath = "C:\test.qvw"

param1 = inputBox("param: ")

set QA = CreateObject("QlikTech.QlikView")

set newdoc = QA.OpenDoc(apppath, "","")

newdoc.Variables("matable").SetContent param1, true

QD.ReloadEx 0,1

QD.save

QD.CloseDoc

QA.Quit

Note that the variable "matable" is declared in my QVW.

MVP & Luminary
MVP & Luminary

Re: Vbs - passing parameters to opendoc or opendocex

This worked:

Option Explicit

Dim QA, QD, apppath, param1, newdoc  

apppath = "C:\test.qvw"

param1 = inputBox("param: ")

set QA = CreateObject("QlikTech.QlikView")

set QD = QA.ActiveDocument.GetApplication

set newdoc = QD.OpenDoc(apppath, "","")

      

newdoc.Variables("matable").SetContent param1, true

      

newdoc.ReloadEx 0,1

newdoc.save

newdoc.CloseDoc

QD.Quit   

- Marcus

Not applicable

Re: Vbs - passing parameters to opendoc or opendocex

Got it working! Thanks Marcus.