Batch Printing of Files from Excel

Last reviewed: November 2, 1994
Article ID: Q48144

The information in this article applies to:

  • Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0a
  • Microsoft Excel for the Macintosh, versions 2.x, 3.0, 4.0

SUMMARY

The following macro prints a batch of files that are all found in the same directory. It requests a directory name and then prints all the files in that directory.

   A1: Batch Print
   A2: =INPUT("Input the Directory of the files to print",2,"Batch
        Print Directory")
   A3: =DIRECTORY(A2)
   A4: =COLUMNS(FILES("*.xl?"))
   A5: =FOR("count",1,A4,1)
   A6: =OPEN(INDEX(FILES("*.xl?"),count),FALSE,FALSE)
   A7: =PRINT()
   A8: =CLOSE()
   A9: =NEXT()
   A10: =RETURN()

If you are using Microsoft Excel for the Macintosh, you need to change lines A4 and A6 as follows:

   A4: =Columns(files(":*"))
   A6: =Open(Index(Files(":*"),count),false,false)

If the directory contains more than 20 files and you are using versions of Microsoft Excel with Microsoft Windows 2.x or the run-time Microsoft Excel, the spooler should be disabled through the WIN.INI file by setting spooler=no. If you are using Microsoft Windows 3.0 or greater, remove the check in the Use Print Manager check box in the Printers dialog box in the Microsoft Windows 3.0 Control Panel.


KBCategory: kbusage
KBSubcategory:

Additional words: 2.0 2.00 2.01 2.1 2.10 3.0 3.00 4.00 4.00a
KBCategory: kbusage
KBSubcategory:


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