Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

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
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

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

johnw
Champion III
Champion III

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
Author

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
Author

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

Anonymous
Not applicable
Author

Did this code "WaitForIdle" crash your application?