Macro to count words in a section, excluding footnotes and end notes

Discussion in 'Word' started by adamyyz, Jan 2, 2017.

  1. adamyyz

    adamyyz

    Joined:
    Jan 2, 2017
    Messages:
    1
    Likes Received:
    0
    Hi,

    I am trying to get a macro to count the words in various sections of a document, but not including the footnote and and note count. Right now i found this on another website and it does what I need but does not remove footnotes and endnotes. Does anyone know how to do that?

    Sub WordCount()
    Dim NumSec As Integer
    Dim S As Integer
    Dim Summary As String



    NumSec = ActiveDocument.Sections.Count
    Summary = "Word Count" & vbCrLf

    For S = 1 To NumSec
    Summary = Summary & "Section " & S & ": " _
    & ActiveDocument.Sections(S).Range.Words.Count _
    & vbCrLf
    Next

    Summary = Summary & "Document: " & _
    ActiveDocument.Range.Words.Count & " " & Footnotes
    MsgBox Summary

    Selection.TypeText Text:=Summary
    End Sub
     
    adamyyz, Jan 2, 2017
    #1
    1. Advertisements

  2. adamyyz

    macropod Microsoft MVP

    Joined:
    Mar 2, 2012
    Messages:
    296
    Likes Received:
    24
    The code you posted doesn't actually include a count of the footnote or endnote content. Simply delete:
    & " " & Footnotes
     
    macropod, Jan 2, 2017
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.