#1
|
|||
|
|||
Count characters on the fly
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 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 |
#2
|
||||
|
||||
Quite apart from whatever issues you macro has (it runs fine for me), I can't see the point - Word gives an active word count on the status bar and retrieving the current character count is as simple as clicking on that count.
Furthermore, a macro that runs every second is liable to conflict with many other operations that take longer than that to complete.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Identifying Irregular Characters | d4okeefe | Word VBA | 2 | 05-09-2013 03:14 PM |
Strange Characters Removal | OceansBlue | Word | 2 | 04-03-2013 10:01 AM |
mail merge (more than 255 characters) | allenglishboy | Mail Merge | 9 | 03-05-2013 06:52 AM |
Junk characters (box-like characters) in Word file | Sashikala | Word | 1 | 04-20-2010 02:03 PM |
escape characters | LadyReader | Word VBA | 0 | 09-06-2006 12:09 PM |