WinWord: Macro to List File Format as 1.x, 2.0, or OtherLast reviewed: February 5, 1998Article ID: Q80816 |
The information in this article applies to:
SUMMARYThis 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 INFORMATIONThis 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.DOCAfter 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 OtherIn 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 MAINChDir "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 SubThe following macro can be used to determine the version of any single file, and will present the information in a message box.
Sub MAINName$ = 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 SubFunction DocVer(name$) Open Name$ For Input As #1 MagicNumber$ = Input$(1, 1)Close #1 If MagicNumber$ = Chr$(220) Then DocVer = 6ElseIf MagicNumber$ = Chr$(219) Then DocVer = 2ElseIf MagicNumber$ = Chr$(155) Then DocVer = 1Else DocVer = 0 'unknown versionEndIf End Function
REFERENCES"Microsoft Word for Windows User's Guide," version 2.0, pages 765-785
|
KBCategory: kbusage kbmacro
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |