Bump. All the macros posted on the MS Office site use Word's built-in citation and referencing types, so I'm manually doing this. A macro will be very helpful.
Having been unable to find a macro, I spent my morning customising various realted ones I found on the internet. The macro below will give you a word count, minus Zotero in text citations and the bibliography, and will also remove the word count for tables and captions. It's slightly clunky, and might give false results if you use any other Add-ins apart from Zotero in your Word document. When I pasted it in below, some of the lines wrapped, and the indentation got lost, so you might want to manually fix this when you create it as a macro.
Sub ExcludeTableCaptionAndZoteroWordsFromWordCount() Dim objTable As Table
With objDoc For Each Fld In .Fields With Fld If .Type = wdFieldAddin Then nZoteroWords = nZoteroWords + .Result.ComputeStatistics(wdStatisticWords) End If End With Next End With
MsgBox ("There are " & nWordCount & " main text words in this document." & vbCr & "The following items are excluded from word count: " & vbCr & "Total words in tables: " & nTableWords & vbCr & "Total caption words: " & nCaptionWords & vbCr & "Total Zotero citation and bibliography words: " & nZoteroWords)
'--- tabeller For Each objTable In objDoc.Tables If objTable.Range.InRange(pageRange) Then nTableWords = nTableWords + objTable.Range.ComputeStatistics(wdStatisticWords) End If Next objTable
'--- captions For Each objParagraph In objDoc.Paragraphs If objParagraph.Style = "Caption" Then If objParagraph.Range.InRange(pageRange) Then nCaptionWords = nCaptionWords + objParagraph.Range.ComputeStatistics(wdStatisticWords) End If End If Next objParagraph
'--- Zotero fields For Each Fld In objDoc.Fields If Fld.Type = wdFieldAddin Then If Fld.Result.InRange(pageRange) Then nZoteroWords = nZoteroWords + Fld.Result.ComputeStatistics(wdStatisticWords) End If End If Next Fld
When I pasted it in below, some of the lines wrapped, and the indentation got lost, so you might want to manually fix this when you create it as a macro.
Sub ExcludeTableCaptionAndZoteroWordsFromWordCount()
Dim objTable As Table
Dim objParagraph As Paragraph
Dim objDoc As Document
Dim nTableWords As Integer
Dim nDocWords As Integer
Dim nWordCount As Integer
Dim nCaptionWords As Integer
Dim Fld As Field
Dim nZoteroWords As Integer
Set objDoc = ActiveDocument
nTableWords = 0
nCaptionWords = 0
nZoteroWords = 0
nDocWords = ActiveDocument.ComputeStatistics(wdStatisticWords)
With objDoc
For Each objTable In .Tables
nTableWords = nTableWords + objTable.Range.ComputeStatistics(wdStatisticWords)
Next objTable
End With
With objDoc
For Each objParagraph In .Paragraphs
If objParagraph.Style = "Caption" Then
nCaptionWords = nCaptionWords + objParagraph.Range.ComputeStatistics(wdStatisticWords)
End If
Next objParagraph
End With
With objDoc
For Each Fld In .Fields
With Fld
If .Type = wdFieldAddin Then
nZoteroWords = nZoteroWords + .Result.ComputeStatistics(wdStatisticWords)
End If
End With
Next
End With
nWordCount = nDocWords - nTableWords - nCaptionWords - nZoteroWords
MsgBox ("There are " & nWordCount & " main text words in this document." & vbCr & "The following items are excluded from word count: " & vbCr & "Total words in tables: " & nTableWords & vbCr & "Total caption words: " & nCaptionWords & vbCr & "Total Zotero citation and bibliography words: " & nZoteroWords)
End Sub
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
Sub ExcludeTableCaptionAndZoteroWordsFromWordCount()
Dim objDoc As Document
Dim pageInput As String
Dim pageRange As Range
Dim rng As Range
Dim objTable As Table
Dim objParagraph As Paragraph
Dim Fld As Field
Dim nDocWords As Long
Dim nTableWords As Long
Dim nCaptionWords As Long
Dim nZoteroWords As Long
Dim nWordCount As Long
Set objDoc = ActiveDocument
'--- ask what page to count
pageInput = InputBox("Which pages to count? (fx 1-3,5,7-10):", _
"Vælg sidetal")
If pageInput = "" Then Exit Sub
'--- make range based on page number
Set pageRange = GetPagesRange(objDoc, pageInput)
If pageRange Is Nothing Then
MsgBox "invalid pagenumber.", vbExclamation
Exit Sub
End If
nDocWords = pageRange.ComputeStatistics(wdStatisticWords)
nTableWords = 0
nCaptionWords = 0
nZoteroWords = 0
'--- tabeller
For Each objTable In objDoc.Tables
If objTable.Range.InRange(pageRange) Then
nTableWords = nTableWords + objTable.Range.ComputeStatistics(wdStatisticWords)
End If
Next objTable
'--- captions
For Each objParagraph In objDoc.Paragraphs
If objParagraph.Style = "Caption" Then
If objParagraph.Range.InRange(pageRange) Then
nCaptionWords = nCaptionWords + objParagraph.Range.ComputeStatistics(wdStatisticWords)
End If
End If
Next objParagraph
'--- Zotero fields
For Each Fld In objDoc.Fields
If Fld.Type = wdFieldAddin Then
If Fld.Result.InRange(pageRange) Then
nZoteroWords = nZoteroWords + Fld.Result.ComputeStatistics(wdStatisticWords)
End If
End If
Next Fld
nWordCount = nDocWords - nTableWords - nCaptionWords - nZoteroWords
MsgBox "Word in maintext (choosen pages): " & nWordCount & vbCr & vbCr & _
"Excluded:" & vbCr & _
"Tabels: " & nTableWords & vbCr & _
"Captions: " & nCaptionWords & vbCr & _
"Zotero: " & nZoteroWords, vbInformation
End Sub
Function GetPagesRange(doc As Document, pageInput As String) As Range
Dim parts() As String
Dim p As Variant
Dim subParts() As String
Dim startPage As Long, endPage As Long
Dim rng As Range
Dim finalRange As Range
parts = Split(pageInput, ",")
For Each p In parts
subParts = Split(Trim(p), "-")
startPage = CLng(subParts(0))
If UBound(subParts) = 1 Then
endPage = CLng(subParts(1))
Else
endPage = startPage
End If
Set rng = doc.GoTo(What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=startPage)
rng.End = doc.GoTo(What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=endPage + 1).Start
If finalRange Is Nothing Then
Set finalRange = rng
Else
finalRange.End = rng.End
End If
Next p
Set GetPagesRange = finalRange
End Function
Or alternatively, as it's very long, host it on GitHub or similar and link to it.