Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calling VBScript in Script

Hi, I'm having a little difficulty with this topic and I can't find out too much information about it.

Essentially, I would like to add a subroutine/function to the loading script that deletes several sheets (this is because I need to maintain several similar versions of the same application, and the sheets are not required in one version).

I created the following subroutine, which works fine in the Edit Module:

SUB RemoveSheets

    ActiveDocument.RemoveSheetByID "TEST"

END SUB

However, I cannot figure out how exactly to call it from the script.  I tried creating it as a function, but this did not work either - I just keep getting a Script line error.  My call in the script is CALL FUNCTION(fRemSts());  Have attached the latest version I had in the Edit Module

I guess I'm missing something really simple, but if anyone could provide some assistance with this I'd be very grateful.

1 Solution

Accepted Solutions
marcus_sommer

I think you are right. Maybe things would be easier if you don't put the sheet-removing routines within the application else using macro-scripts from outside (another qvw or external vbs-file) which might loop through a filelist of qvw and do this and that.

- Marcus

View solution in original post

6 Replies
marcus_sommer

Hi Ricky,

you couldn't call a sub-routine only the way per function worked - but only code worked which didn't need an ActiveDocument which only exists after the reload is finished.

- Marcus

Not applicable
Author

Thanks Marcus, I guess that would explain the fact that when I'm in the Edit Module, and I run the subroutine using the Test button, it works exactly as desired (and also using a button that references the macro).

So is it not possible then to refer to ActiveDocument properties during the load script then?

What also works is to call the subroutine on Open Document - but ideally I would delete all the sheets, and have the advantage of a smaller file size, before the user interacts with it.

Not applicable
Author

Okay, I now see this has already been covered, apologies:

Calling VB script macro from load script

Therefore, in order to automate the deletion of sheets, I could map the subroutine to a button within the application, and then set another document to press this button (via a separate .vbs file).

Seems a bit cumbersome though - are there are any better alternatives, does anyone know?

marcus_sommer

Why do you want to remove the sheets from the applications? I have often hidden sheets - per conditions on osuser() - which contains specialized export & print objects, administrative things like the structur-table and temp-sheets for testing this and that.

- Marcus

Not applicable
Author

I'd like to remove the sheets because one version of the document only has one sheet displayed to the end user.  However, it is very slow to load (and is also being loaded by another document, using WebPageViewer (Improved WebPageViewer QlikView Extension (WebPageViewer2)).

There is no point having all these sheets in the stripped down version, and since there are about 15 of them, with numerous graphs and tables, I am trying to do as much as I can to reduce the overall file size.  But I have to maintain the applications together because they share a lot of variables etc.

Rob Wunderlich's Document Analyzer helped a lot, but it would be great to reduce things still further.

marcus_sommer

I think you are right. Maybe things would be easier if you don't put the sheet-removing routines within the application else using macro-scripts from outside (another qvw or external vbs-file) which might loop through a filelist of qvw and do this and that.

- Marcus