Microsoft KB Archive/80816

{|
 * width="100%"|

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

 * }

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 &quot;c:\winword&quot; DocName$ = Files$(&quot;*.doc&quot;) While DocName$ <> &quot;&quot; Open DocName$ For Input As #1 Test$ = Input$(1, 1) Insert DocName$ + Chr$(9) If Test$ = Chr$(219) Then Insert &quot;2.0&quot; InsertPara ElseIf Test$ = Chr$(155) Then Insert &quot;1.x&quot; InsertPara ElseIf Test$ = Chr$(220) Then Insert &quot;6.0&quot; InsertPara Else Insert &quot;Other&quot; 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$(&quot;Type the path and name of the file you wish to verchek:&quot;) MsgBox UCase$(Name$) + Chr$(13) + &quot;was created under W4W Version&quot; + Str$(DocVer(name$))+&quot;.&quot; 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