WinWord: Macro to List File Format as 1.x, 2.0, or Other

Last reviewed: February 5, 1998
Article ID: Q80816
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

SUMMARY

This article contains a Microsoft Word for Windows macro that searches a specified group of files on a directory and lists each the format of each file as one of the following:

  • 1.x (for files in Word for Windows version 1.0 or 1.1 format)
  • 2.x (for files in Word for Windows version 2.x format)
  • 6.0 (for files in Word for Windows version 6.0 format)
  • Other (for files in a format other than 1.x or 2.x)

MORE INFORMATION

This macro is useful for determining whether a file is in Word for Windows version 1.x . 2.x or 6.0 file format. It searches the specified directory and lists each file, followed by the indicator of its format. In the macro below, all the files with a .DOC file extension in the C:\WINWORD directory are listed and identified by file format. For example, you could search a directory containing the following four files:

   MYFILE1.DOC
   MYFILE2.DOC
   MYFILE3.DOC
   MYFILE4.DOC


After you run the macro, the files are listed in the active document as follows:

   MYFILE1.DOC     1.x
   MYFILE2.DOC     2.0
   MYFILE3.DOC     6.0
   MYFILE4.DOC     Other

In the above example, MYFILE1.DOC is Word for Windows version 1.x file format, MYFILE2.DOC is Word for Windows version 2.0 file format, and MYFILE3.DOC is a Word for Windows 6.0 and MYFILE4.Doc is a format other than Word for Windows version 1.x, 2.0. or 6.0

Macros

Sub MAIN
ChDir "c:\winword" DocName$ = Files$("*.doc")
     While DocName$ <> ""
     Open DocName$ For Input As #1
     Test$ = Input$(1, 1)
     Insert DocName$ + Chr$(9)
     If Test$ = Chr$(219) Then
          Insert "2.0"
          InsertPara
     ElseIf Test$ = Chr$(155) Then
          Insert "1.x"
          InsertPara
     ElseIf Test$ = Chr$(220) Then
          Insert "6.0"
          InsertPara
     Else
          Insert "Other"
          InsertPara
     End If
     Close #1
     DocName$ = Files$()
Wend
End Sub

The following macro can be used to determine the version of any single file, and will present the information in a message box.

Sub MAIN
Name$ = InputBox$("Type the path and name of the file you wish to verchek:") MsgBox UCase$(Name$) + Chr$(13) + "was created under W4W Version" + Str$(DocVer(name$))+"."
End Sub

Function DocVer(name$) Open Name$ For Input As #1
 MagicNumber$ = Input$(1, 1)
Close #1 If MagicNumber$ = Chr$(220) Then
 DocVer = 6
ElseIf MagicNumber$ = Chr$(219) Then
 DocVer = 2
ElseIf MagicNumber$ = Chr$(155) Then
 DocVer = 1
Else
 DocVer = 0 'unknown version
EndIf End Function

REFERENCES

"Microsoft Word for Windows User's Guide," version 2.0, pages 765-785


KBCategory: kbusage kbmacro
KBSubcategory:
Additional query words: 1.x 1.0 1.1 1.1a 2.0 winword2 winword 6.0c
winword word6 2.0a 2.0a-CD 2.0b 2.0c wordbasic determine
Version : 2.x 6.0 6.0a 6.0c
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.