Hi to all
A friend of mine (a journalist) asked me to write a macro—if possible—that counts characters on the fly, as his articles are limited to fixed numbers of characters.
I googled a lot on Application.OnTime and found numerous (timer) examples for Excel. Unfortunately Word's OnTime has no 'Schedule:=False' parameter so I use one OnTime to re-call the procedure until a second OnTime stops the first one.
Code:
Option Explicit
Dim iTimerSet As Double
Dim bTimer As Boolean
Sub CountCharsOnTime()
If Not bTimer Then Exit Sub
iTimerSet = Now + TimeValue("00:00:01")
Application.StatusBar = "Anzahl Zeichen = " & _
ActiveDocument.BuiltInDocumentProperties(wdPropertyCharsWSpaces)
Application.OnTime iTimerSet, "CountCharsOnTime"
End Sub
Sub TimerOnOff()
bTimer = Not bTimer
If Not bTimer Then
Application.OnTime Now, "TimerTaskEnded"
Else
CountCharsOnTime
End If
End Sub
Sub TimerTaskEnded()
Application.StatusBar = "Fertig ..."
End Sub
The macro works fine within his document, or at least seems to … . But as soon as I copy it into my 'AllMarcos' AddInn it fails in line "Application.OnTime iTimerSet, "CountCharsOnTime"" with a "sub or procedure not found" message.
So my question: What goes wrong with my solution. A macro that only sometimes works does not really help.
Any ideas? Any help appreciated.
NP