Microsoft Office Tutorials and References
In Depth Information
Excel Procedures
'Screen Updating¶
Application.ScreenUpdating = False¶
'Store current calculation method in variable¶
OldCalculation = Application.Calculation¶
'Set calculation to manual¶
Application.Calculation = xlCalculationManual¶
Application.DisplayAlerts = False¶
Application.EnableEvents = False¶
'Use Excel's built-in search engine¶
With Application.FileSearch¶
'Feed the parameters¶
.LookIn = Folder¶
.SearchSubFolders = LookInSubFolders¶
'Look only for Excel workbooks¶
.FileType = msoFileTypeExcelWorkbooks¶
'Execute the search, return number files found if any¶
If .Execute() > 0 Then¶
'Loop through each file¶
For Counter = 1 To .FoundFiles.Count()¶
'Open the file, using the "File" workbook as the variable¶
Set File = Workbooks.Open(Filename:=.FoundFiles(Counter), _¶
UpdateLinks:=False, ReadOnly:=True)¶
'Print to the default printer¶
'Print only one copy (change the 1 as needed)¶
File.PrintOut Copies:=1¶
'Close the workbook, without saving changes¶
File.Close SaveChanges:=False¶
'Next file¶
Next Counter¶
'No files found, notify the user¶
MsgBox "No files found", vbCritical¶
End If¶
End With¶
'Restore settings¶
Application.EnableEvents = True¶
Application.DisplayAlerts = True¶
Application.Calculation = OldCalculation¶
'Screen Updating¶
Application.ScreenUpdating = True¶
End Sub¶
You can change the information in the 'Change the following variables' section
by changing the path in which to look for the files and setting the
Search JabSto ::

Custom Search