Printing the information within a number of files without opening them all individually

splash

Board Regular
Joined
Oct 12, 2004
Messages
74
Hi all

I have an issue that I would be very appreciative of your help with:

I have a large number of excel files with a standard worksheet in a standard layout. I need to print each of these workbooks - can I do this without opening all the files individually?

Any assistance with this would be very much appreciated

Thanks a lot in advance
Splash
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
They will still need to be opened to be printed, but you don't have to do it manually.

Rich (BB code):
Option Explicit

Sub OpenPrintAllInFolder()
Dim wbToPrint As Workbook   'this will vary as each wb is opened
Dim shName As String        'the string holding the name of the sht to print
Dim fName As String
Dim fPath As String         'the folder that holds the files

shName = "Invoice"          'change this to match the sheet to print
fPath = "C:\2011\"          'don't forget the final \ in this path string

On Error Resume Next
Application.ScreenUpdating = False

fName = Dir(fPath & "*.xls")    'get the first filename

Do While Len(fName) > 0         'loop until no more filenames are found
    
    Set wbToPrint = Workbooks.Open(fPath & fName)
    Sheets(shName).PrintOut     'print the specified sheet
    wbToPrint.Close False       'close, no changes
    fName = Dir                 'get next filename

Loop
    
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top