Microsoft Office Tutorials and References
In Depth Information
Excel Procedures
'Screen Updating¶
Application.ScreenUpdating = False¶
'Calculation¶
'Store current calculation method in variable¶
OldCalculation = Application.Calculation¶
'Set calculation to manual¶
Application.Calculation = xlCalculationManual¶
'Alerts¶
Application.DisplayAlerts = False¶
'Events¶
Application.EnableEvents = False¶
'Use Excel's built-in search engine¶
With Application.FileSearch¶
.NewSearch¶
'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¶
Else¶
'No files found, notify the user¶
MsgBox "No files found", vbCritical¶
End If¶
End With¶
'Restore settings¶
'Events¶
Application.EnableEvents = True¶
'Alerts¶
Application.DisplayAlerts = True¶
'Calculation¶
Application.Calculation = OldCalculation¶
'Screen Updating¶
Application.ScreenUpdating = True¶
End Sub¶
Exl
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