Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 06-11-2013, 07:17 AM
gmaxey gmaxey is offline A recurring word count macro? Windows 7 32bit A recurring word count macro? Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub SectionWordCount()
Dim lngIndex As Long
Dim oRng As Word.Range
Dim strBMName As String
Dim strCount As String
  With ActiveDocument
    For lngIndex = 1 To .Sections.Count
      strCount = "(" + Format(.Sections(lngIndex).Range.ComputeStatistics(wdStatisticWords)) + " words)"
      strBMName = "WordCount" & "_" & lngIndex
      On Error Resume Next
      Set oRng = .Bookmarks(strBMName).Range
      If Err.Number <> 0 Then
        Set oRng = .Sections(lngIndex).Range
        oRng.Collapse wdCollapseEnd
        If Asc(oRng.Characters(1).Previous) = 12 Then
          oRng.Move wdCharacter, -1
        End If
      Else
        oRng.Delete
      End If
      oRng.Text = vbCr & strCount
      oRng.MoveStart wdCharacter, 1
      .Bookmarks.Add Name:=strBMName, Range:=oRng
    Next
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Count Richtriebe Word 1 04-20-2013 11:09 AM
A recurring word count macro? Word Count Macro bpanda Word VBA 1 01-11-2013 06:51 PM
A recurring word count macro? Where did live word count go? Tango Mike Word 3 08-01-2012 09:34 PM
*Word 2007 Macro for Character Count gbartlet Word 0 07-21-2010 11:12 AM
FInd recurring words in Word 2003 NJ007 Word 4 01-25-2010 03:11 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:41 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