Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2014, 03:37 AM
NobodysPerfect NobodysPerfect is offline Count characters on the fly Windows 7 64bit Count characters on the fly Office 2010 32bit
Competent Performer
Count characters on the fly
 
Join Date: Jan 2014
Location: Germany
Posts: 136
NobodysPerfect is on a distinguished road
Default 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
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
Reply With Quote
  #2  
Old 04-20-2014, 03:39 PM
macropod's Avatar
macropod macropod is offline Count characters on the fly Windows 7 32bit Count characters on the fly Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Count characters on the fly Identifying Irregular Characters d4okeefe Word VBA 2 05-09-2013 03:14 PM
Count characters on the fly Strange Characters Removal OceansBlue Word 2 04-03-2013 10:01 AM
Count characters on the fly 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft