Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
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.
John/Oleg,
Thank you both so very much for your help - I've learned something from both your responses.
All the best,
Nick
Hello friend, this loop with macro how do I stop running when you click the button again?
Did this code "WaitForIdle" crash your application?