Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Why VB script that runs in Excel doesn't in Qlikview 12?

I am new to Qlikview.

I wrote a VB script to write a Table Box in a csv file within Macro Edit Module in Qlikview and doesn't run

Why?

Would you please help me to solve this incident?

Below there are the script for QV and Excel. In Excel, I create a QV application object and included Qlikview 12.0 Type Library.

I am using Qlikview 12.0 Personal Edition.

Thanks!

VB script in QV:

Sub runRScore

          ' Export the selected patient data to be scored.

          Set myTable = ActiveDocument.GetSheetObject("DataSentToR")

          myTable.Export (CurrentPath & "//data//ExportFile.csv"), ","

End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function CurrentPath()

'Set qvApp = New QlikView.Application

'     Set Doc = qvApp.ActiveDocument

    Set v = ActiveDocument.GetVariable("vAppPath")

    CurrentPath = Replace(v.GetContent.String,"\","/")

End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

VB script in Excel:

Sub runRScore()

Set qvApp = New QlikView.Application

     Set Doc = qvApp.ActiveDocument

          ' Export the selected patient data to be scored.

          Set myTable = Doc.GetSheetObject("DataSentToR")

          myTable.Export (CurrentPath & "//data//ExportFile.csv"), ","

         

         

End Sub

Function CurrentPath()

Set qvApp = New QlikView.Application

     Set Doc = qvApp.ActiveDocument

    Set v = Doc.GetVariable("vAppPath")

    CurrentPath = Replace(v.GetContent.String, "\", "/")

End Function

2 Replies
marcus_sommer

I don't think that your approach will work. Take a look here on the various examples which export mostly to excel (but this could be changed) to get a better idea how the code should look like:

https://community.qlik.com/search.jspa?q=macro+excel+export&type=document

Another useful source for macro-coding is this: Useful Qlikview Macros and of course the APIGuide.qvw within your installation is a great source to statements, parameters and the object-model.

- Marcus

Not applicable
Author

Hi Marcus,

Thanks for your recommendation. Actually, I made two changes in the scripts I originally posted:

  • Remove declarative sentences of QV application, and change Doc Object by ActiveDocument
  • Change the name of script file by the name of macro subroutine

Anyway, I've seen some of the post you recommended in your comment and some seems to be interesting and helpful.

Best,

Rafael