AnsweredAssumed Answered

PI processbook - CountDown timer

Question asked by GuillaumeMar on May 27, 2020
Latest reply on May 27, 2020 by gregor

Hello,

 

I create a userform on PI Processbook in order to display some messages.

I would like that the message changes every 5 seconds.

I found on Excel application the following code : Excel.Application.OnTime Now + TimeValue(Format(waitingTime, "hh:mm:ss")), "loopToDisplayMessage"

 

The problem is that PI Processbook does not recognize this code. I have an error message "Cannot run the macro 'LoopToDisplayMessage'. The macro may not be available in this workbook or all macros may be disabled". The screenshot is in attachment.

So I search a similar method for PI Processbook.

 

Thanks for your help,

G.

 

Below the entire sub procedure :

 

Sub loopToDisplayMessage()

 

' Issue with the OnTime method. Work with Excel but not with PB
Do While stopLoop = False

' Get the message to display
Dim i As Long
Dim com() As Variant
ReDim com(0, UBound(communicationToDisplay, 2))
For i = 0 To UBound(communicationToDisplay, 2)
    com(0, i) = communicationToDisplay(cmpt_loop, i)
    'Debug.Print (com(0, i))
Next i
' Display the message on the userform
AffichageCommunication (com)

' incrémentation du compteur (when last message, go to first message)
cmpt_loop = cmpt_loop + 1
If cmpt_loop > UBound(communicationToDisplay, 1) Then
    cmpt_loop = 0
End If

' Timer
Dim waitingTime As Single
waitingTime = 5
waitingTime = Timer(waitingTime)
Excel.Application.OnTime Now + TimeValue(Format(waitingTime, "hh:mm:ss")), "loopToDisplayMessage"

 

Loop


End Sub

Attachments

Outcomes