Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Debugging QlikView VBScript

As it can be seen in the other posts concerning this topic,

since QlikView Version 10.0 there is no longer any debugging functionality for VBScript in Qlikview.

And it seems that QlikTech is not willing to integrate debugging tools in the near future

Without a debugger writing VBScript Code can be very hard.

Therefore I tried another approach: Why not use the integrated debugger in Microsoft Excel?

To be able to debug via Excel I took the following steps:

  • I installed the QlikView Plugin (which is also needed for the enhanced WebView of QlikView in the IE)
  • I created a new empty Excel document and copied all the VBScript Code that I want to debug from QV into an Excel VBA module
  • In order to communicate with QlikView I added the following references to the VBA project (they should be simply selectable when the plugin is installed):
    • QlikOCX ActiveX Control module
    • QlikView 11.0 Type Library
  • Due to small incompatibilities between QV and Excel VBA some minor code adaption have to be made
    • Global variables may not be initialised outside a Sub or Function in Excel. Therefore I have to change my script to only declarare global variables, and to move all Initialisation to a newly created Sub init(), which I have to call before I start the actual debugging
    • If I want to call a Sub or Function in QV I only need to write "function_abc(var1)". In Excel VBA I need to change that to "CALL function_abc(var1)"
  • I created a new Sub Debug() that I use to debug the QV code:
    • Call Init()     'Initialise global variables
    • Set qvApp = New QlikView.Application     'gives you access to QV. If you have more than 1 QV instances opened, the last opened is returned
    • Set qvDoc = qvApp.ActiveDocument     'gives you access to the QV ActiveDocument. In your QV script you have to replace every usage of "ActiveDocument" by the variable qvDoc, which references the active document!
    • Call qv_function_you_want_to_debug
  • At last I created a button in Excel and linked its click event to the Debug() procedure

After all this steps the Excel debugger can be used and everything works quite well. The need to adapt the code is a little drawback, but If you try to design your initial QV code according to the Excel incompatibilities, then this is no big deal.

Has anybody else experiences with a debugging solution?  Do you think the solution described is useful or do you have any suggestions or enhancements?

I'm looking forward to any comments 🙂

Kind regards

Chris

19 Replies
IAMDV
Luminary Alumni
Luminary Alumni

Great idea Chris. I always struggled debugging VB Script. I generally do that with the MsgBox approach! I understand it's not ideal but something is better than nothing.

What do you mean by - "I installed the QlikView Plugin (which is also needed for the enhanced WebView of QlikView in the IE)"? In your first point...

Thanks,

DV

www.QlikShare.com

Not applicable
Author

There is a QlikView plugin used for the native look of QlikView Apps in the IE.

This plugin also contains the *.ocx files needed for the Excel integration.

As the plugin is a part of the QlikView desktop client installation it should be already installed and you can skip that step 🙂

Chris

IAMDV
Luminary Alumni
Luminary Alumni

Okay cool. So you are referring to the IE plug-in right?

Thanks,

DV

www.QlikShare.com

Not applicable
Author

Yep right, it's the IE plugin...

Peter_Brunner
Creator
Creator

Hi Chris,

I have been trying to setup your great suggestion and have got everthing going except for the

  • Call qv_function_you_want_to_debug
  • do you have some sample code or even better
  • a sample of excel script I could look at and workout the syntax used here.

thanks regards Peter

Not applicable
Author

Sub Init()

    '***Init Global Variables (e.g. newline or tab character)

  vNl = Chr(13) & Chr(10)

    vTab = Chr(9)

 

    '***If Code will be executed in Excel debugger, ActiveDocument is empty

    If ActiveDocument = Empty Then

     '***First a new QlikView App needs to be created, to be able to access the ActiveDocument and to be able to store a reference in variable doc

           Set qvApp = New QlikView.Application

     Set doc = qvApp.ActiveDocument

    '***If the code is run directly inside the QlikView client (and not inside Excel)

    Else

           '***ActiveDocument can be accessed directly

     Set doc = ActiveDocument

    End If

 

End Sub

Sub qv_function_you_want_to_debug()

    '***Call Init Sub to initialize ActiveDocument and all global variables.

    Init

  MsgBox doc.Name

  '*** Put your code that you want to debug here 🙂

End Sub

Hope this code example helps... If you have further questions, do not hesitate to ask me.

If you tell me what you want to do and send me you code, I can further assist you...

Kind regards

Chris

Peter_Brunner
Creator
Creator

Hi Chris

thanks for this I will have a look and let you know

have a good Xmas

regards Peter

Not applicable
Author

Hi Chris,

Would you mind posting a sample excel file with a linked QV document?

I am struggling with the vbscript debugging and it would be much appreciated!

I actually got it working! Thanks a ton. This opened up alot of new possibilities for us!

Thanks,

Viggo

Not applicable
Author

Perfect
I'm always happy if my work is also helpful for anybody else 🙂

Kind regards

Chris