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

ID: Q80816

The information in this article applies to:

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:

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

Last Reviewed: February 5, 1998