Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Luis_Galvan
Contributor III
Contributor III

QlikView: Extract Script from QVW\QVF - Automated

Have anyone run successfully a code to extract the scripts from QVW\QVFs files in QlikView into QVS using an external code such PowerShell, VBS, Python, etc.? The catch is that the code must

1. Loop all QVW\QVF files in a directory share folder (all sub-folders and files in those sub-folders).

2. Needs to run in non-interactive mode (back-end)

I have created a code in PowerShell, and it is running as expected, but it only runs through an interactive session. I used the concept build in the document analyzer version in https://qlikviewcookbook.com/2017/01/the-document-analyzer-compare-tool/ built by Rob Wunderlich. I have a challenge to run it in non-interactive mode as the code can only open the QlikView application using COMObject cmd:

$qv = New-Object -ComObject QlikTech.QlikView

How can I open the QlikView application as it would be running from QMC (task)?

Thank you for any advice

Qlik Architect || QV || QS || Nprinting
Labels (2)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think my Script Repository tool is just about what you need:

Qlikview Cookbook: Script Repository https://qlikviewcookbook.com/recipes/download-info/script-repository/

It was designed to be capable of running non-interactive, but I just tested and had to make a couple of tweaks. 

1. In the ScriptRepository_V19.qvw, open the Module and copy all the vbscript. Paste the copied script into a new file ScriptRepository.vbs.

2. Edit the vbs file and make the following changes. 

a. Function IsInternal: just force it to always false like this:

Function IsInternal
  IsInternal = false
End Function
 
b. In Sub ProcessDocument, comment or remove the line:
If IsInternal() AND (qvwFullPath = ActiveDocument.GetPathName) Then Exit Sub
 
c. In the open section around line 79, add these lines after CONST EXTRACT_LOGFILE_NAME = "QvScriptExtract.log"
 

CONST EXTRACT_LOGFILE_NAME = "QvScriptExtract.log"

rootInDir = WScript.Arguments(0)
rootOutdir = WScript.Arguments(1)
Call MainExtractScript

 

Save the vbs file and now you can run from command line like:

cscript //NoLogo ScriptExtract.vbs c:\your-qvw-dir c:\script-output-dir

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

 

View solution in original post

4 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think my Script Repository tool is just about what you need:

Qlikview Cookbook: Script Repository https://qlikviewcookbook.com/recipes/download-info/script-repository/

It was designed to be capable of running non-interactive, but I just tested and had to make a couple of tweaks. 

1. In the ScriptRepository_V19.qvw, open the Module and copy all the vbscript. Paste the copied script into a new file ScriptRepository.vbs.

2. Edit the vbs file and make the following changes. 

a. Function IsInternal: just force it to always false like this:

Function IsInternal
  IsInternal = false
End Function
 
b. In Sub ProcessDocument, comment or remove the line:
If IsInternal() AND (qvwFullPath = ActiveDocument.GetPathName) Then Exit Sub
 
c. In the open section around line 79, add these lines after CONST EXTRACT_LOGFILE_NAME = "QvScriptExtract.log"
 

CONST EXTRACT_LOGFILE_NAME = "QvScriptExtract.log"

rootInDir = WScript.Arguments(0)
rootOutdir = WScript.Arguments(1)
Call MainExtractScript

 

Save the vbs file and now you can run from command line like:

cscript //NoLogo ScriptExtract.vbs c:\your-qvw-dir c:\script-output-dir

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

 

Luis_Galvan
Contributor III
Contributor III
Author

I will test this out, but looks promising. Thanks @rwunderlich 

Qlik Architect || QV || QS || Nprinting
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You have to tweak it to look for qlikview qvf as well as qvw.

-Rob

Luis_Galvan
Contributor III
Contributor III
Author

It is working as expected, and running in the non-interactive (non opening QV Desktop). Added the option to allow both QVW or QVF files and worked too. 

Thanks

 

Qlik Architect || QV || QS || Nprinting