Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to make a button unpressable when macro was running

hi, I have a problem.

I have a qvw with a button ,and a macro in it.

The macro is for execute a vbs on the local Disk.

My problem is when the button was  pressed and the vbs is running at the background(for example 30 seconds),

the button is pressable and if I press it again,the vbs also executed once again.

Is there any solution to make the button unpressable when macro was running?

(I'm running the qvw on the AccessPoint)

thank you

1 Solution

Accepted Solutions
marcus_sommer

One way might be to put a condition into the button-availability (tab general) which counts the seconds against another value - but it would need to run permanent now() against the system (and it's not easy to implement a stable logic).

Another very easy method would be to set a sleep-statement after calling the vbs like:

ActiveDocument.GetApplication.Sleep 30000

If this isn't suitable because the application would be unusable in this time I would store the execution-time from the macro into a variable and check them at first within the routine and only if now() - ExecutionTimeVariable > 30 seconds I would execute the vbs and otherwise do nothing (or maybe give the user a msgbox with an info).

- Marcus

View solution in original post

5 Replies
marcus_sommer

One way might be to put a condition into the button-availability (tab general) which counts the seconds against another value - but it would need to run permanent now() against the system (and it's not easy to implement a stable logic).

Another very easy method would be to set a sleep-statement after calling the vbs like:

ActiveDocument.GetApplication.Sleep 30000

If this isn't suitable because the application would be unusable in this time I would store the execution-time from the macro into a variable and check them at first within the routine and only if now() - ExecutionTimeVariable > 30 seconds I would execute the vbs and otherwise do nothing (or maybe give the user a msgbox with an info).

- Marcus

Peter_Cammaert
Partner - Champion III
Partner - Champion III

I wouldn't make the button "unpressable" because that would force the creation of a too complex solution in your QlikView document that would never be entirely satisfactory. The QV environment isn't particularly well suited for communicating with the outside world.

I would solve this in a different way: make the vbs script non-restartable. The first thing the vbs script would do is check for the existence of a temporary file with a specific name (e.g. _InUse.!!! - indeed, stolen from the Distribution Service ) If this zero-length file exists, the vbs script leaves immediately without doing anything. If not, the actual script starts by creating this file and doing whathever it needs to do. At the end of the script run, the special file is removed before exiting.

This special file is used as a sort of semaphore lock that restricts execution to a single instance at all times.

Best,

Peter

m_woolf
Master II
Master II

I suggest adding a line at the beginning of your macro that hides the button and a line at the end that unhides it.

Not applicable
Author

thank you for your answer.

infact , i've tried [ActiveDocument.GetApplication.Sleep 30000] and the result is , it works well on the LocalClient but not on the AccessPoint.

by the way ,how to show a msgbox on the AccessPoint?

I tried vbs's [msgbox] and it shows nothing ( but in the LocalClient ,it works)

marcus_sommer

The normal answers is that macros won't work within the AJAX client (only desktop client + IE plugin - there are some qmc-settings necessary) but I had read that nevertheless some basic routine will work.

An alternative for a msgbox could be to use two textboxes which content and visibility is controlled by variables and to change the variable-values with the macro-routine (the second textbox is used to close/hide the first one and itself).

- Marcus