Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I need to create an external program that pre loads the sales data from sql server and stores it in a sales.qvd file. If I run the script from the open qvw file the data is loaded without errors, but from my vb program I am getting a HResult com error
{"Error HRESULT E_FAIL has been returned from a call to a COM component."}
here is the code from vb program
Dim QvDoc As New QlikView.ActiveDocument
QvDoc = GetObject("....\marketing_sales_data\SalesLoader.qvw")
QvDoc.Reload()
QvDoc.CloseDoc()
Basically I need to retreive data from sql server and save in sales.qvd. What is the proper way of doing this?
The proper way would be to use the command line syntax for QlikView and run a bat file or similar with:
C:\Path\Qv.exe /r C:\Path\QvFile.qvw
Another approach is to use QlikView Server/Publisher and reload on a schedule that way.
On a sidenote; to launch a QlikView instance from VBScript and run a reload you could use the following example. However, the Qv.exe /r Filename.qvw is a better solution.
rem ** VBScript **
set test= CreateObject("QlikTech.QlikView")
set newdoc = test.OpenDoc ("C:\Folder\Document.qvw","user","pass")
test.Reload
test.Save
test.Quit
Thanks for your great reply:
I got this to work :
Dim QvApp As New QlikView.Application
Dim QvDoc As QlikView.ActiveDocument
'Load sales from sql database and save results to sales.qvd file
QvDoc = QvApp.OpenDoc("...\marketing_sales_data\SalesLoader.qvw")
QvDoc.Reload()
QvDoc.CloseDoc()
Hi Johannes
Your vbscript works similar to my vb code except I have the same problem of the database credentials login dialog box that opens and request the password eventhough I am supplying it in the connection string.
I have an idea, is it possible to create a sales.qvd file from vb using ole. This way I would execute the query from vb code and save results to the sales.qvd file without openning the qvw file?
Here is my workaround for the login credentials dialog box.
In my VB prog I connect to my sql server and execute my query and save the dataset to a csv file
then I open my qvw document and load the contents of the csv and store it in the qvd file. I will post some sample code here shortly
How can we make the vbscript execution wait for the document reload to finish? Currently when I execute the vbscript, it completes immediately but the Qlikview App reload is still executing.
It is possible to fully automate reports generation from Qlikview (Both PDF Aand Excel)
See below link -