Microsoft KB Archive/89653

{|
 * width="100%"|

WD: WordBasic Macros to Test for Annotations and Footnotes

 * }

Q89653

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows NT, version 6.0
 * Microsoft Word for Windows 95, versions 7.0, 7.0a
 * Microsoft Word for the Macintosh, versions 6.0, 6.0.1

-

SYMPTOMS
In Microsoft Word, the ViewFootnotes and ViewAnnotations macro commands will return the following error messages if there are no annotations or footnotes in the active document:

Word found no footnotes

Word found no annotations

To avoid the above error messages you can test for the presence of footnotes or annotations in a document before using the ViewFootnotes or ViewAnnotations commands.

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code &quot;as is&quot; without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

The following Word macro will test for the presence of automatic footnotes in your document:

Note: This macro will not work with Word version 6.0 for the Macintosh. The CommandValidfunction does not work with the ViewFootnotes command. The macro does work with Word version 6.0.1 for the Macintosh.

  Sub MAIN n = CommandValid(&quot;ViewFootnotes&quot;) If n <> - 1 Then MsgBox &quot;There are no footnotes in this document.&quot; Else StartOfDocument EditFind .Find = &quot;^f&quot;, .Direction = 0 If EditFindFound Then MsgBox &quot;There are footnotes in this document&quot; Else MsgBox &quot;There are no footnotes in this document.&quot; End If     End If   End Sub If you are using Word version 2.x for Windows, change the EditFind statement in the above macro to the following:

EditFind .Find = &quot;^2&quot;, .Direction = 2 The following Word macro will test for the presence of annotations in your document:

  Sub MAIN n = CommandValid(&quot;ViewAnnotations&quot;) If n <> - 1 Then MsgBox &quot;There are no annotations in this document.&quot; Else StartOfDocument EditFind .Find = &quot;^a&quot;, .Direction = 0 If EditFindFound Then MsgBox &quot;There are annotations in this document&quot; Else MsgBox &quot;There are no annotations in this document.&quot; End If     End If   End Sub If you are using Word version 2.x for Windows, change the EditFind statement in the above macro to the following:

EditFind .Find = &quot;^5&quot;, .Direction = 2

Macro Notes

 * The CommandValid command returns -1 if the &quot;ViewAnnotations&quot; or &quot;ViewFootnotes&quot; commands are available. In addition to checking whether the appropriate View command is valid, the above macros use the EditFind command to search for footnotes or annotation reference marks.
 * The .Find argument in the EditFind command uses &quot;^f&quot; to find automatic footnote reference marks and &quot;^a&quot; to find annotation reference marks.
 * The EditFindFound function tests whether a footnote reference or annotation reference was found in the above macros. You can replace the MsgBox commands with the logical branches of your macro.

For information about how to do this in Word 97 for Windows or Word 98 Macintosh Edition, please see the following article(s) in the Microsoft Knowledge Base:

"Q158854 WD97: Compile Error If VB Code Doesn't Find Comments"