Article ID: 107880
Article Last Modified on 10/10/2006
Sub Batch_Print()
Dim Input_Dir, Print_File As String
Input_Dir = InputBox _
("Input directory path containing the files to print")
' Defines Print_File equal to the first Microsoft Excel file found
' in the directory specified in the InputBox above.
Print_File = Dir(Input_Dir & "\*.xl*")
' If you are using Microsoft Excel for the Macintosh, you need
' to change Print_File = Dir(Input_Dir & "' .xl*") to
'
' If you are using Microsoft Excel 5.0, use this line
' Print_File = Dir(Input_Dir & ":", MacID("XLS5"))
'
' If you are using Microsoft Excel 98, use this line
' Print_File = Dir(Input_Dir & ":", MacID("XLS8"))
'
' and change Workbooks.Open Filename:=Input_Dir & "\" & Print_File
' to:
'
' Workbooks.Open Filename:=Input_Dir & ":" & Print_File
' Loops through the directory specified in the above InputBox
' and opens each workbook in the directory, prints all sheets
' in the workbook and closes the workbook. Continues until are
' all files are printed.
Do While Len(Print_File) > 0
Workbooks.Open Filename:=Input_Dir & "\" & Print_File
ActiveWorkbook.PrintOut Copies:=1
ActiveWorkbook.Close
Print_File = Dir()
Loop
End Sub
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: 8.00 XL
Keywords: kbdtacode kbhowto kbprogramming KB107880