Thread: [Solved] Word Count Macro
View Single Post
 
Old 01-10-2013, 10:15 PM
bpanda bpanda is offline Mac OS X Office for Mac 2011
Novice
 
Join Date: Jan 2013
Posts: 3
bpanda is on a distinguished road
Default Word Count Macro

I got this Word Count macro that I copied from somewhere. It works very well but I have forgotten how it works. All I remember is that it appears to count the number of words in a section or in a part of a section. I have a bookmark called abstract that it uses to identify where to start or stop counting. Can anyone figure this out?

Code:
Sub AbstractWordCount()
'
' AbstractWordCount Macro
'
'
Dim oRange As Word.Range
Dim sBookmarkName As String
Dim sTemp As String
 
sBookmarkName = "abstract"
With ActiveDocument
  sTemp = " " + Format(.Sections(3).Range.Words.Count, "0")
  Set oRange = .Bookmarks(sBookmarkName).Range
  oRange.Delete
  oRange.InsertAfter Text:=sTemp
  .Bookmarks.Add Name:=sBookmarkName, Range:=oRange
End With
 
End Sub

Last edited by macropod; 01-29-2013 at 08:45 PM. Reason: Added code tags & formatting
Reply With Quote