You are on page 1of 12

Application

Pgina 1 de 12

Application
The QlikView program

Method Detail
ActiveDocument
Document ActiveDocument()

VBScript:Returns the QlikView document in control of the macro


VB:Returns the currently active QlikView document.
Earliest version:
4.0x
Example:
set Doc = ActiveDocument
ActiveDocument.ClearAll false

rem ** Create an untyped reference from VB **


set Qv = CreateObject("QlikTech.QlikView")
set ActiveDocument = Qv.ActiveDocument

CreateDoc
Document CreateDoc()

Creates a new QlikView document.


Earliest version:
6.0x
Example:
ActiveDocument.GetApplication.CreateDoc

CreateEmptyReport
IReport CreateEmptyReport()

Creates an empty report object.


Earliest version:
7.01
Example:
set rep = ActiveDocument.GetApplication.CreateEmptyReport
rep.Name = "MyNewReport"
rep.Comment = "Sample report"
rep.Pages.Add
rep.Pages.Item(0).Landscape = true
rep.Pages.Item(0).PageMode = 0
'single paper page
rep.Pages.Item(0).Items.Add
rep.Pages.Item(0).Items.Item(0).ObjectId = "CH21"
rep.Pages.Item(0).Items.Item(0).Rect.Top = 0 'top
rep.Pages.Item(0).Items.Item(0).Rect.Left = 0 'left
rep.Pages.Item(0).Items.Item(0).Rect.Height = 0.5 'half paper height
rep.Pages.Item(0).Items.Item(0).Rect.Width = 0.5 'half paper width
ActiveDocument.AddDocReport rep

DisableCtlBrk
DisableCtlBrk()

Disables the possibility to interupt macro execution with Ctrl+Break.


Earliest version:
5.0x
Example:
rem ** disable ctrl brk **
ActiveDocument.GetApplication.DisableCtlBrk

EnableCtlBrk
EnableCtlBrk()

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 2 de 12

Enables the possibility to interupt macro execution with Ctrl+Break.


Earliest version:
5.0x
Example:
rem ** enable ctrl brk **
ActiveDocument.GetApplication.EnableCtlBrk

GetAffinity
Integer GetAffinity(Integer CoreNo)

Returns affinity status for a specified core. For debug use only!!
Parameters:
CoreNo (Integer)

: Core number (0 based)

Returns:
Returns affinity status for a specified core
0 = off
1 = on
-1 = non-existing core number
Earliest version:
8.01
Example:
i = Activedocument.GetApplication.GetAffinity 1

'returns status of core#2

GetCachePercentage
Integer GetCachePercentage()

Returns object cache as percentage of total RAM. For debug use only!!
Earliest version:
8.01
Example:
msgbox(Activedocument.GetApplication.GetCachePercentage)

GetCommittedMemory
Double GetCommittedMemory()

Returns currently commited memory. For debug use only!!


Earliest version:
8.01
Example:
msgbox(Activedocument.GetApplication.GetCommittedMemory)

GetCpuMilliseconds
Double GetCpuMilliseconds()

Returns number of CPU milliseconds used by the current instance of QlikView.


Earliest version:
7.51
Example:
t = ActiveDocument.GetApplication.GetCpuMilliseconds

GetElapsedMilliseconds
Double GetElapsedMilliseconds()

Number of milliseconds since Windows started.


Earliest version:
7.20
Example:
msgbox(ActiveDocument.GetApplication.GetElapsedMilliseconds)

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 3 de 12

GetEmptyRect
IRect GetEmptyRect()

Returns an empty rectangle object (for VBScript).


Earliest version:
6.0x
Example:
set R = ActiveDocument.GetApplication.GetEmptyRect

GetMajorVersionDate
String GetMajorVersionDate()

Returns major version date (For LEF upgrade check).


Earliest version:
6.0x
Example:
msgbox(ActiveDocument.GetApplication.GetMajorVersionDate)

GetProcessId
Integer GetProcessId()

Returns process ID.


Earliest version:
8.00
Example:
msgbox(ActiveDocument.GetApplication.GetProcessId)

GetProperties
IApplicationProperties GetProperties()

Returns QlikView properties.


Earliest version:
4.0x
Example:
msgbox(ActiveDocument.GetApplication.GetProperties.Computername)

GetRunLevel
short GetRunLevel()

Current QlikView level.


Earliest version:
7.20
Example:
msgbox(ActiveDocument.GetApplication.GetunLevel)

GetServerDocList
IArrayOfDocListEntry GetServerDocList(String Server)

Returns list of available documents on from a QlikView Server.


Parameters:
Server (String)

: QlikView Server URL

Returns:
List of available documents on from a QlikView Server returned
Earliest version:
6.0x

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 4 de 12

Example:
set app = ActiveDocument.GetApplication
set docs = app.GetServerDocList("qvp://@www.qliktech.com")
for i = 0 to docs.Count-1
set doc = docs.Item(i)
msgbox(doc.DocName)
msgbox(doc.FileSize)
msgbox(doc.Filetime)
next

GetSolidColorArea
IColorAreaDef GetSolidColorArea(Byte Red, Byte Green, Byte Blue)

Returns a solid one-color color area.


Parameters:
Red (Byte) : Red component of desired color (0-255)
Green (Byte) : Green component of desired color (0-255)
Blue (Byte) : Blue component of desired color (0-255)
Returns:
Color area definition object returned
Earliest version:
6.0x
Example:
set Graph = ActiveDocument.ActiveSheet.CreateBarChart
Graph.AddDimension "ProductType"
Graph.AddExpression "sum(Amount)"
col = ActiveDocument.GetApplication.GetSolidColorArea(255,0,0)
Graph.AddRefLine "10.5",2,col
'red at 10.5 on primary y

'red

GetTotalPhysicalMemory
Double GetTotalPhysicalMemory()

Returns total physical memory. For debug use only!!


Earliest version:
8.01
Example:
msgbox(Activedocument.GetApplication.GetTotalPhysicalMemory)

GetUserPreferences
IUserPreferences GetUserPreferences()

Returns User Preferences.


Earliest version:
4.0x
Example:
Cp = ActiveDocument.GetApplication.GetUserPreferences.ConfirmPurge
if Cp=true then msgbox("Warning! No Reduce Data confirmation!")

InputBox
String InputBox(String label, String DefaultValue)

Launches an input dialog. Replaces old QvLib method


Parameters:
label (String) : Label text to be shown above the edit area of thge input dialog
DefaultValue (String) : Optional initial value to be displayed in edit area of input dialog
Returns:
Value entered into edit area of input dialog returned
Earliest version:
6.0x
Example:
rem VBScript
sub TestModule
name = ActiveDocument.GetApplication.InputBox("What is your name?")
msg = "Hello "
msg = msg + name + " !"
qvlib.MsgBox(msg)
end sub

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 5 de 12

// JScript
function Test()
{
personName = ActiveDocument.GetApplication.InputBox("What is you name?")
msg = "Hello " + personName + " !"
qvlib.MsgBox(msg)
}

InputBoxEx
String InputBoxEx(String label, String DefaultValue)

Launches a sizable multi-line input dialog.


Parameters:
label (String) : Label text to be shown above the edit area of thge input dialog
DefaultValue (String) : Optional initial value to be displayed in edit area of input dialog
Returns:
Value entered into edit area of input dialog returned
Earliest version:
7.51
Example:
rem the variable MyVariable must exist for macro to work!
oldtext = ActiveDocument.Evaluate("MyVariable")
t = ActiveDocument.GetApplication.InputBoxEx("Enter text:",oldtext)
ActiveDocument.Variables("MyVariable").SetContent t,true

Launch
Boolean Launch(String Application, String Parameters)

Launches a named Windows application.


Parameters:
Application (String) : Path and filename for application program to
Parameters (String) : Parameters to launched application program

launch

Returns:
No return value
Earliest version:
4.0x
Example:
rem ** Example 1 **
set app= ActiveDocument.GetApplication
app.Launch "C:\Program Files\Winword.exe","C:\Myfiles\abc.doc"

LoadNewerDoc
Boolean LoadNewerDoc()

Replaces active (remote) document with newer version on server, if one exists.
Earliest version:
8.00
Example:
ActiveDocument.GetApplication.GetNewerDoc

MsgBox
Integer MsgBox(String str, Integer type)

MsgBox function for Jscript. Replaces old QvLib method


Parameters:
str (String) : Text to be shown in message box
type (Integer) : Buttons to be shown in dialog
0 = OK (default)
1 = OK,CANCEL
2 = ABORT,RETRY,IGNORE
3 = YES,NO,CANCEL
4 = YES,NO
5 = RETRY,CANCEL
Returns:
Button pressed when exiting dialog
1 = OK
2 = CANCEL

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 6 de 12

3 = ABORT
4 = RETRY
5 = IGNORE
6 = YES
7 = NO
Earliest version:
6.0x
Example:
ActiveDocument.GetApplication.MsgBox("Hello world")

OpenDoc
Document OpenDoc(String DocName, String UserName, String Password, String Serial)

Opens a QlikView document.


Parameters:
DocName (String) : QV document file name (qvw
UserName (String) : QlikView document UserID
Password (String) : QlikView document Pwd
Serial (String) : Reserved

or qva) with path

Returns:
QlikView document returned
Earliest version:
4.0x
Example:
rem ** VBScript **
set App = ActiveDocument.GetApplication
set newdoc = App.OpenDoc ("C:\MyDocuments\QV4Automation.qvw","","")
set App = ActiveDocument.GetApplication
App.OpenDoc "C:\MyDocuments\Budget.qvw","JNN","123456"
rem ** Visual Basic **
dim App as New QlikView.Application
set newdoc = App.OpenDoc ("C:\MyDocuments\Budget.qvw","JN","123456")

OpenDocEx

Document OpenDocEx(String DocName, short AccessMode, Boolean AllowDialog, String UserName, String Password, String Serial, Boolean NoData, Boolean UseD

Opens a document with silent fail.


Parameters:
DocName (String) : QV document file name (qvw
AccessMode (short) : Requested access mode

or qva) with path

0 = unspecified
1 = admin
2 = user
AllowDialog (Boolean) : True if error messages to appear
UserName (String) : Section access user name to be used
Password (String) : Section access password to be used
Serial (String) : Section access serial number to be used
NoData (Boolean) :
UseDocStartState (Boolean) :
Returns:
QlikView document returned
Earliest version:
6.0x
Example:
set App = ActiveDocument.GetApplication
App.OpenDocEx "C:\MyDocuments\Budget.qvw",2,false,"jnn","123456","",false

OSName
String OSName()

Returns name of operating system.


Earliest version:
5.0x
Example:
msgbox(ActiveDocument.GetApplication.OSName)

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 7 de 12

OSVersion
String OSVersion()

Returns version number of operating system.


Earliest version:
5.0x
Example:
msgbox(ActiveDocument.GetApplication.OSVersion)

PerformLef
Boolean PerformLef()

Invokes the LEF editor dialog.


Earliest version:
7.20
Example:
ActiveDocument.GetApplication.PerformLef

PerformRegistration
Boolean PerformRegistration()

Invokes the license number registration dialog.


Earliest version:
7.20
Example:
ActiveDocument.GetApplication.PerformRegistration

QTProduct
String QTProduct()

Returns QlikTech Product name.


Earliest version:
5.0x
Example:
msgbox(ActiveDocument.GetApplication.QTProduct)

Quit
Quit(Integer ExitCode)

Closes the QlikView program.


Parameters:
ExitCode (Integer)

: Exit code for QlikView program

Returns:
No return value
Earliest version:
4.0x
Example:
rem ** quit QlikView **
ActiveDocument.GetApplication.Quit

QvVersion
String QvVersion()

Returns QlikView version number.


Earliest version:
4.0x

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 8 de 12

Example:
rem ** show current QV version **
msgbox(ActiveDocument.GetApplication.QvVersion)

Refresh
Refresh()

Forces a redraw od the QlikView window.


Earliest version:
5.0x
Example:
rem ** Refresh screen **
ActiveDocument.GetApplication.Refresh

RemoveAllBuffers
Integer RemoveAllBuffers()

Removes all QVD buffers.


Earliest version:
7.00
Example:
ActiveDocument.GetApplication.Remove AllBuffers

RevokeClassObjects
RevokeClassObjects()

Revokes class factories for QlikView Automation thereby detaching the current instance and opening up for additional instances of QlikView to act as
Automation servers.
Earliest version:
7.00
Example:
ActiveDocument.GetApplication.RevokeClassObjects

ScreenHeight
Integer ScreenHeight()

Returns height of current screen resolution in pixels.


Earliest version:
5.0x
Example:
rem ** show current screen height **
msgbox(ActiveDocument.GetApplication.ScreenHeight)

ScreenWidth
Integer ScreenWidth()

Returns width of current screen resolution in pixels.


Earliest version:
5.0x
Example:
rem ** show current screen width **
msgbox(ActiveDocument.GetApplication.ScreenWidth)

SetAffinity
Integer SetAffinity(Integer CoreNo, Integer Mode)

Sets affinity status for a specified core. For debug use only!!
Parameters:

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 9 de 12

CoreNo (Integer) : Core number


Mode (Integer) : 0 = turn off

(0 based)

1 = turn on
Returns:
Returns status after operation
0 = off
1 = on
-1 = non-existing core number
Earliest version:
8.01
Example:
Activedocument.GetApplication.SetAffinity 1,1

'turns on core#2

SetCachePercentage
SetCachePercentage(Integer Percentage)

Sets object cache as percentage of total RAM. For debug use only!!
Parameters:
Percentage (Integer)

: Percentage of physical RAM

Returns:
No return value
Earliest version:
8.01
Example:
Activedocument.GetApplication.SetCachPercentage 15

SetProperties
SetProperties(IApplicationProperties Properties)

Sets the QlikView properties.


Parameters:
Properties (IApplicationProperties)

: Application properties object. Note! Not equal to Application Properties in UI (=IDocumentProperties)

Returns:
No return value
Earliest version:
4.0x
Example:
set QVProp = ActiveDocument.GetApplication.GetProperties
QVProp.UserID="John"
ActiveDocument.GetApplication.SetProperties QVProp

SetUserPreferences
SetUserPreferences(IUserPreferences Preferences)

Sets User Preferences.


Parameters:
Preferences (IUserPreferences)

: User perefernces object

Returns:
No return value
Earliest version:
4.0x
Example:
set UP = ActiveDocument.GetApplication.GetUserPreferences
UP.ConfirmPurge = true
ActiveDocument.GetApplication.SetUserPreferences UP

ShowBookmarksBar
ShowBookmarksBar(Integer Mode)

Sets show-mode for bookmarks toolbar.


Parameters:
Mode (Integer) : Show mode for toolbar
0 = hide
1 = docked top

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 10 de 12

2 = docked left
3 = docked bottom
4 = docked right
5 = floating
Returns:
No return value
Earliest version:
7.00
Example:
ActiveDocument.GetApplication.ShowBookmarksBar 1

' docked top

ShowDesignBar
ShowDesignBar(Integer Mode)

Sets show-mode for design toolbar.


Parameters:
Mode (Integer) : Show mode for toolbar
0 = hide
1 = docked top
2 = docked left
3 = docked bottom
4 = docked right
5 = floating
Returns:
No return value
Earliest version:
7.00
Example:
ActiveDocument.GetApplication.ShowDesignBar 1

' docked top

ShowMenuBar
ShowMenuBar(Integer Mode)

Sets show-mode for menubar.


Parameters:
Mode (Integer) : Show mode for menu bar
0 = hide
1 = docked top
2 = docked left
3 = docked bottom
4 = docked right
5 = floating
Returns:
No return value
Earliest version:
7.00
Example:
ActiveDocument.GetApplication.ShowMenuBar 1

' docked top

ShowNavigationBar
ShowNavigationBar(Integer Mode)

Sets show-mode for navigation toolbar.


Parameters:
Mode (Integer) : Show mode for toolbar
0 = hide
1 = docked top
2 = docked left
3 = docked bottom
4 = docked right
5 = floating
Returns:
No return value
Earliest version:
7.00
Example:
ActiveDocument.GetApplication.ShowNavigationBar 1

' docked top

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 11 de 12

ShowSelectionWindow
Boolean ShowSelectionWindow(Boolean Show)

Turns current selection window on/off.


Parameters:
Show (Boolean) : True if window to be shown
Returns:
Selections windows status before operation (true = on)
Earliest version:
4.0x
Example:
rem ** turn selection window on **
ActiveDocument.GetApplication.ShowSelectionWindow true

ShowSheetsBar
ShowSheetsBar(Integer Mode)

Sets show-mode for sheets toolbar.


Parameters:
Mode (Integer) : Show mode for toolbar
0 = hide
1 = docked top
2 = docked left
3 = docked bottom
4 = docked right
5 = floating
Returns:
No return value
Earliest version:
7.00
Example:
ActiveDocument.GetApplication.ShowSheetsBar 1

' docked top

ShowStandardBar
ShowStandardBar(Integer Mode)

Sets show-mode for standard toolbar.


Parameters:
Mode (Integer) : Show mode for toolbar
0 = hide
1 = docked top
2 = docked left
3 = docked bottom
4 = docked right
5 = floating
Returns:
No return value
Earliest version:
7.00
Example:
ActiveDocument.GetApplication.ShowStandardBar 1

' docked top

ShowStatusBar
ShowStatusBar(Boolean Show)

Sets show-mode for statusbar.


Parameters:
Show (Boolean) : True if status bar is to be shown
Returns:
No return value
Earliest version:
7.00
Example:
ActiveDocument.GetApplication.ShowBookmarksBar false

'hide

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

Application

Pgina 12 de 12

Sleep
Sleep(Integer MilliSec)

Pauses QlikView for a specified time.


Parameters:
MilliSec (Integer)

: Number of milliseconds to pause QlikView

Returns:
No return value
Earliest version:
4.0x
Example:
rem ** let QV sleep for 10 seconds **
ActiveDocument.GetApplication.Sleep 10000

WaitForIdle
Boolean WaitForIdle(Integer MilliSecTimeout)

Holds macro execution until all layout entities have been updated.
Parameters:
MilliSecTimeout (Integer)

: Optional timeout in milliseconds after which macro execution will resume regardless of idle state or not

Returns:
True returned if idle state was reached (no timeout)
Earliest version:
7.51
Example:
ActiveDocument.GetApplication.WaitForIdle

file:///C:/Users/Opss/Downloads/QlikViewAPI_html/Application.htm

17/03/2016

You might also like