Microsoft KB Archive/89653

From BetaArchive Wiki

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 "as is" 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 CommandValid()function does not work with the ViewFootnotes command. The macro does work with Word version 6.0.1 for the Macintosh.

   Sub MAIN
      n = CommandValid("ViewFootnotes")
      If n <> - 1 Then
         MsgBox "There are no footnotes in this document."
      Else
         StartOfDocument
         EditFind .Find = "^f", .Direction = 0
         If EditFindFound() Then
            MsgBox "There are footnotes in this document"
         Else
            MsgBox "There are no footnotes in this document."
         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 = "^2", .Direction = 2 

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

   Sub MAIN
      n = CommandValid("ViewAnnotations")
      If n <> - 1 Then
         MsgBox "There are no annotations in this document."
      Else
         StartOfDocument
         EditFind .Find = "^a", .Direction = 0
         If EditFindFound() Then
            MsgBox "There are annotations in this document"
         Else
            MsgBox "There are no annotations in this document."
         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 = "^5", .Direction = 2 



MORE INFORMATION

Macro Notes

  • The CommandValid command returns -1 if the "ViewAnnotations" or "ViewFootnotes" 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 "^f" to find automatic footnote reference marks and "^a" 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



REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, page 325 and 327

"Microsoft Word for Windows User's Guide," version 2.0, pages 265-266

Additional query words: winword2 word95 word7 word6 errmsg err msg viewannotations viewfootnotes macword winword

Keywords : wordnt kbmacroexample winword ntword macword word6 word7 word95
Issue type : kbhowto kbinfo
Technology : kbHWMAC kbOSMAC kbWordSearch kbWordMacSearch kbWord700Search kbZNotKeyword2 kbZNotKeyword3 kbWord600Mac kbWord601Mac kbWord600 kbWord600a kbWord600c kbWord200 kbWord200a kbWord200b kbWord200c kbWord700 kbWord600NT kbWord700a


Last Reviewed: November 5, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.