Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 



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 04:05 AM.


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