Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
Not applicable

Trying to Loop through Sheets in a Dashboard Continually

Hi all,

Trying to put together a dashboard that contains (e.g. 10 sheets) each with different content.

I'd like to have a sheet with a button that kicks off a loop that displays each sheet for (e.g. 10 seconds) and then moves on to the next one.

I've used a little code like this:

for i = 0 to ActiveDocument.NoOfSheets - 1
ActiveDocument.Sheets(ActiveDocument.Sheets(i).GetProperties.Name).Activate
ActiveDocument.GetApplication.Sleep 5000
next

But I can't seem to get the desktop client to actually show any page between the first and the last page, let alone get it looping through continually. When I apply the above code to a macro attached to a button, it whirrs away but only displays the final sheet....never showing the intermediate sheets.

Any ideas?

Many thanks!

Nick

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Trying to Loop through Sheets in a Dashboard Continually

Add WaitForIdle into your loop:

for i = 0 to ActiveDocument.NoOfSheets - 1
ActiveDocument.Sheets(ActiveDocument.Sheets(i).GetProperties.Name).Activate
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.GetApplication.Sleep 5000
next

View solution in original post

5 Replies
MVP & Luminary
MVP & Luminary

Trying to Loop through Sheets in a Dashboard Continually

Add WaitForIdle into your loop:

for i = 0 to ActiveDocument.NoOfSheets - 1
ActiveDocument.Sheets(ActiveDocument.Sheets(i).GetProperties.Name).Activate
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.GetApplication.Sleep 5000
next

View solution in original post

MVP
MVP

Trying to Loop through Sheets in a Dashboard Continually

It starts automatically instead of being controlled by a button, but attached is one way of handling this sort of requirement without a macro. A table defines how long it should spend on each sheet, and then a display condition on each sheet determines when that sheet should display. You could easily kick it off with a button by, say, having the button set a variable that the condition for each sheet also checks.

Not applicable

Trying to Loop through Sheets in a Dashboard Continually

John/Oleg,

Thank you both so very much for your help - I've learned something from both your responses.

All the best,

Nick

Not applicable

Trying to Loop through Sheets in a Dashboard Continually

Hello friend, this loop with macro how do I stop running when you click the button again?

danilodct
New Contributor III

Re: Trying to Loop through Sheets in a Dashboard Continually

Did this code "WaitForIdle" crash your application?