The following macro should do what you describe - as always, this could be
done in different ways. For details, see the comments in the macro. As you
can see, I have also included manual line breaks and paragraph marks as
characters to check for since a footnote could also include any of these and
nothing else. If you do not want that, you can remove “Chr(11)†and “Chr(13)â€
from oArray.
Sub MarkEmptyFootnotes()
Dim oFootnote As Footnote
Dim strMsg As String
Dim strText As String
Dim oArray As Variant
Dim n As Long
'Start msg to show when finished
strMsg = "The following footnotes were empty:" & vbCr
'Define the characters that are to be considered "nothing"
'i.e. spaces, tabs, paragraph marks, manual line breaks
oArray = Array(" ", vbTab, Chr(11), Chr(13))
For Each oFootnote In ActiveDocument.Footnotes
'If text consists of spaces/tabs only, insert string
With oFootnote
strText = .Range.Text
'Remove any of the array chars from the footnote text string
For n = LBound(oArray) To UBound(oArray)
strText = Replace(strText, oArray(n), "")
Next n
'If the string is now empty, insert text in footnote
If strText = "" Then
.Range.Text = "No entry as yet"
'Append footnote number to msg
strMsg = strMsg & .Index & vbCr
End If
End With
Next oFootnote
MsgBox strMsg, vbOKOnly, "Result of Footnote Check"
End Sub
--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmarkwww.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
andreas said:
I wonder whether the following task can be achieved using Word VBA.
If there are blank footnotes in my active document [i.e. no characters/
words have been entered in the footnotes other than (a) space(s) or
tabstop(s)] ...
.... a text string, such as "no entry as yet" should be entered in
those blank footnotes. Also a msgbox should list the footnote number
where entries have been made.
Thank you very much in advance for your help.
Regards, Andreas- Hide quoted text -
- Show quoted text -