Accessing QlikView documents from outside QlikView
QlikView documents can be accessed by means of the Automation interface from outside the QlikView program via e.g. Visual Basic (VB) or Visual Basic for Applications (VBA).
Before using QlikView Automation with typed calls you must include the QlikView type library (embedded in QV.EXE). In Visual Basic Studio this is done using the References command on the Project menu.
Information noteThe ActiveDocument method used from VB provides a reference to the currently active QlikView document!
Examples
Information noteThese examples are for VB/VBA only. They do not work for VBScript!
Example 1:
rem ** VB/VBA Example 1 **
Private Sub OpenAndReload_Click()
rem ** Open QV with named document **
set QvDoc = GetObject("c:\MyDoc.qvw")
QvDoc.Reload
End Sub
Example 2:
rem ** VB/VBA Example 2 **
Private Sub GetCurrentlyActiveDocument()
dim ActiveDoc as new QlikView.ActiveDocument
rem ** ActiveDoc points to active document in open QV. **
rem ** The QlikView program must be started and have a **
rem ** previously opened document. **
…
End Sub
Example 3:
rem ** VB/VBA Example 3 **
Private Sub Ex2()
Dim doc1 As New QlikView.ActiveDocument
rem ** doc1 is set to active document in open QV **
Set Appl = doc1.GetApplication
rem ** Appl points at QV program **
rem ** Appl.ActiveDocument points at doc1 **
Set doc2 = Appl.OpenDoc("C:\MyDoc.qvw", "", "")
doc2.Activate
rem ** Appl.ActiveDocument now points at doc2 **
rem ** Note difference from VBScript! **
…
End Sub