someone provided me code earlier this week on how to print all the xls sheets in a directory... is it possible to alter that code to include word documents?
lemme find the code...
i would like to include subdirectories if that is possible...
choose a single "root" and print all worksheets from all work books and all word documents in all the sub directories in the order they appear in windows
lemme find the code...
Code:
Sub PrintAllWS()
Dim wb As Workbook
Dim ws As Worksheet
Dim MyFolder
Dim I As Long
Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
MyFolder = GetFolder
If MyFolder = vbNullString Then
MsgBox "No folder selected. Please select a folder to print.", vbCritical
Exit Sub
End If
With Application.FileSearch
.NewSearch
.LookIn = MyFolder
.FileType = msoFileTypeExcelWorkbooks
.Execute
For I = 1 To .FoundFiles.Count
Set wb = Workbooks.Open(.FoundFiles(I))
For Each ws In wb.Worksheets
ws.PrintOut
Next ws
wb.Close
Next I
End With
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Private Function GetFolder() As String
'common UDF for getting a folder name
Dim ff As Object
Set ff = CreateObject("Shell.Application"). _
BrowseForFolder(0, "Please select a folder", 0, "c:\\")
If Not ff Is Nothing Then
GetFolder = ff.Items.Item.Path
Else
GetFolder = vbNullString
End If
End Function
i would like to include subdirectories if that is possible...
choose a single "root" and print all worksheets from all work books and all word documents in all the sub directories in the order they appear in windows