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

VBscript error: Object required: 'WScript'

Hi,

I have a macro that exports an object to a CSV file.

I would like to display a message when the export starts and one when it is done. The first message should not require the user to click ok. So msgbox is not an option.

From the net I plucked this:
Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")

BtnCode = WshShell.Popup("Export started", 10)

The macro doesn't work:

Object required: 'WScript'



Note: security is set to System Access and Allow System Access.

QV 8.5

Any suggestions?

Thanks

Anton

10 Replies
llauses243
Creator III
Creator III

Hi,

i not use wscript. and funct

good luck, Luis

Not applicable
Author

Hi Luis,

Thanks. Now I get the pop-up, but it is waiting for the user to click ok. I does not go away after 10 seconds as it should...

Anton

Not applicable
Author

Hi all,

No solution yet...

Does anyone know of a way to show a message during the execution of a macro that does not require any action from the user?

In other words: showing a message that does not interupt the macro execution?

Thanks

Anton

pljsoftware
Creator III
Creator III

Hello Anton,

I had the same problem and I solved it by removing the word WScript before CreateObject


'Correct
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("calc.exe")
'NOT Correct
Set WshShell = WScript. CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("calc.exe")

Regards

Luca Jonathan Panetta

PLJ Software

azimabadi
Creator III
Creator III

Thank you Luca,

this helped me so much!

Regards

Peyman

azimabadi
Creator III
Creator III

can i close this application(i.e. calc.exe) from my script too?

Best Regards

Peyman

pljsoftware
Creator III
Creator III

Hi Peyman,

look these

http://ss64.com/vb/exec.html

http://www.excelforum.com/excel-programming-vba-macros/480065-how-to-close-an-application.html

But NOTE that the use of Terminate can generate memory leaks.

Regards

Luca Jonathan Panetta

PLJ Software

Not applicable
Author

was there a solution to this?

petter
Partner - Champion III
Partner - Champion III

A tiny modification of the script he found on the internet will make it work in a Module/Macro/VBScript in QlikView:

2017-02-16 03_40_08-Edit Module.png

If you leave out WScript in front of the CreateObject() it will work.

Furthermore you have to change these two settings from safe mode in the Edit Module Editor:

Requested Module Security:  System Access

Current Local Security: Allow System Access

The code should be wrapped in a sub routine to:

2017-02-16 03_56_38-Edit Module.png

BTW: The timeout that is supposed to work is a bug in the WShell component in Windows. Has nothing to do with QlikView. So putting a value for timeout like 10 seconds will never work... You will have to press a button.