Word.Tips.Net Welcome toWord.Tips.Net

Helpful Links

Tips.Net Home
WordTips Home

Ask a Word Question
Make a Comment

Tips.Net Store

WordTips FAQ
WordTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

Newest Tips

Printing On Both Sides of the Paper

Turning Off AutoComplete for Dates

Ordering Search and Replace

Understanding Auto Line Spacing

Adding Comments to Your Document

Conditional Calculations in Word

Determining Word Frequency

 

Counting Characters in a Selection with VBA

Summary: Need to figure out the number of characters in a range of selected text? Here's how to do it in VBA. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)

When you are developing macros, it is often helpful to know how many characters are in a text selection. The following VBA macro, CharCount, will display the number of characters in a selection.

Sub CharCount()
    Dim Title As String
    Dim CharCount As Integer
    Dim Message As String

    Title = "CharCount"
    CharCount = Len(Selection)
    Message = LTrim(Str(CharCount)) + " character"
    If CharCount <> 1 Then Message = Message + "s"
    MsgBox Message, vbOKOnly, Title
End Sub

Tip #746 applies to Microsoft Word versions: 97 | 2000 | 2002 | 2003

Document and Annotate! One of the easily overlooked tools provided by Word is the ability to add footnotes and endnotes to your documents. WordTips: Footnotes and Endnotes is the definitive resource guide to using these tools to enhance your documents.
 
Check out WordTips: Footnotes and Endnotes today!