![]() |
#9
|
||||
|
||||
![]()
Hi Jamal,
The following macro gives you a wide range of statistics Code:
Sub CountWords() Application.ScreenUpdating = False Dim oTbl As Table, lTbl As Long, Sctn As Section Dim oHdFt As HeaderFooter, lHdr As Long, lFtr As Long Dim oEnt As Endnote, lEnt As Long Dim oFnt As Footnote, lFnt As Long Dim oShp As Shape, lShp As Long Dim oPara As Paragraph, lCpt As Long With ActiveDocument For Each oTbl In .Tables lTbl = lTbl + oTbl.Range.ComputeStatistics(wdStatisticWords) Next For Each oEnt In .Endnotes lEnt = lEnt + oEnt.Range.ComputeStatistics(wdStatisticWords) Next For Each oFnt In .Footnotes lFnt = lFnt + oFnt.Range.ComputeStatistics(wdStatisticWords) Next For Each Sctn In .Sections For Each oHdFt In Sctn.Headers If Not oHdFt.LinkToPrevious Then _ lHdr = lHdr + oHdFt.Range.ComputeStatistics(wdStatisticWords) Next For Each oHdFt In Sctn.Footers If Not oHdFt.LinkToPrevious Then _ lFtr = lFtr + oHdFt.Range.ComputeStatistics(wdStatisticWords) Next Next For Each oShp In .Endnotes If Not oShp.TextFrame Is Nothing Then _ lShp = lShp + oShp.TextFrame.TextRange.ComputeStatistics(wdStatisticWords) Next For Each oPara In .Paragraphs If oPara.Style = "Caption" Then _ lCpt = lCpt + oPara.Range.ComputeStatistics(wdStatisticWords) Next MsgBox "Word Count Statistics:" & vbCr & _ "Tables - " & vbTab & vbTab & lTbl & vbCr & _ "EndNotes - " & vbTab & lEnt & vbCr & _ "Footnotes - " & vbTab & lFnt & vbCr & _ "Headers - " & vbTab & vbTab & lHdr & vbCr & _ "Footers - " & vbTab & vbTab & lFtr & vbCr & _ "Shapes - " & vbTab & vbTab & lShp & vbCr & _ "Captions - " & vbTab & lCpt & vbCr & _ "Other - " & vbTab & vbTab & .Range.ComputeStatistics(wdStatisticWords) - lTbl - lCpt End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
When Printing a file Sources/Details included | BigTunz | Word | 0 | 03-01-2010 01:24 AM |
Hide contact details | AndyKC | Outlook | 0 | 01-25-2010 11:00 PM |
Transfer of account details to Outlook 2003 on Windows7 | taralastair | Outlook | 1 | 01-04-2010 01:24 PM |
Printing task details | STEVEK | Outlook | 0 | 11-11-2009 06:02 AM |
Entering Contact details | GemmaD | Outlook | 0 | 12-18-2008 06:41 AM |