WD: WordBasic Macro to Generate Catalog of Clip-Art Pictures

Last reviewed: February 2, 1998
Article ID: Q86710
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 95, versions 7.0, 7.0a
  • Word for the Macintosh, versions 6.0, 6.0.1

SUMMARY

This article contains a macro that you can use in Microsoft Word to display or print a catalog of the graphic images in Word. This macro is helpful because there is no printed documentation showing the graphic images in Word.

These images are located in the CLIPART subdirectory. The macro below creates a document, inserts each graphic image in a table (three images per row), and lists the filename of each image. Note: There is a limit of 200 total images built into this macro.

MORE INFORMATION

   Sub MAIN
      ' Dimension an array to hold the filenames of the images.
      Dim f$(200)
      ' Insert a three column table to provide a columnar place to
      ' display the images.
      TableInsertTable .NumColumns = "3"
      ' Loop through all the filenames that meet the specified
      ' image type using the Files$() function from WordBasic.
      i = 0
      file$ = Files$("*.wmf")
      f$(i) = file$
      While file$ <> ""
         file$ = Files$()
         i = i + 1
         f$(i) = file$
      Wend
      ' Now that the filenames are stored in an array, loop
      ' through the array and bring in the images.
      For j = 0 To i - 1
         ' First insert the filename and a paragraph mark.
         Insert f$(j)
         InsertPara
         ' Now insert the picture and some paragraph marks.
         InsertPicture  f$(j)
         CharLeft 1, 1
         CharRight
         InsertPara
         InsertPara
         InsertPara
         ' Use the NextCell command to generate a new row in the table.
         NextCell
     Next  j
   End Sub

NOTE: Word 6.x for the Macintosh users, replace the line:

   file$ = Files$("*.wmf")

with:

   file$ = Files$(MacID("PICT"))

Using This Macro

To use this macro, follow these steps:

  1. Make the directory that contains the images the current directory by choosing Open from the File menu and double-clicking the appropriate directory in the Directories box. Choose the Cancel button.

  2. Change the line in the macro that reads

          file$ = Files$("*.wmf")
    

    to reflect the appropriate extension of the pictures you want to view. For example, if you are generating a catalog of .BMP images that were created in Paintbrush, the line should read as follows:

          file$ = Files$("*.bmp")
    

  3. Create a new document and run the macro.


Additional query words: hard copy
Keywords : macword ntword winword winword2 word6 word7 word95 wordnt kbmacro
Version : WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1,6.0.6.0.1a
Platform : MACINTOSH Win95 WINDOWS winnt
Issue type : kbhowto


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 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.