ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing multiple (selected) workbooks (https://www.excelbanter.com/excel-programming/396611-printing-multiple-selected-workbooks.html)

markx

Printing multiple (selected) workbooks
 
Hello guys,

I was checking the web (and found nothing) for a macro that would allow me
to print multiple workbooks, a bit like with the "right-click/print"
function in MS Explorer. This function has however two drawbacks:
- prints only the first worksheet (and not the total workbook)
- opens the file (so it's slower), and - very often - "unnecessarily" asks
if I want to save the file before closing and opening the next one.

Do you know how should such an 'enhanced' macro look like? Thanks for any
suggestions.
Regards,

Mark



Bernie Deitrick

Printing multiple (selected) workbooks
 
Mark,

Sub PrintAllSheetsInUserSelectedFiles()
Dim FileArray As Variant
Dim myBook As Workbook
Dim mySht As Worksheet

FileArray = Application.GetOpenFilename(MultiSelect:=True)
If IsArray(FileArray) Then
For i = LBound(FileArray) To UBound(FileArray)
Workbooks.Open FileArray(i)
Set myBook = ActiveWorkbook
For Each mySht In myBook.Worksheets
mySht.PrintOut
Next mySht
myBook.Close False
Next i
End If
End Sub

HTH,
Bernie
MS Excel MVP


"markx" wrote in message
...
Hello guys,

I was checking the web (and found nothing) for a macro that would allow me to print multiple
workbooks, a bit like with the "right-click/print" function in MS Explorer. This function has
however two drawbacks:
- prints only the first worksheet (and not the total workbook)
- opens the file (so it's slower), and - very often - "unnecessarily" asks if I want to save the
file before closing and opening the next one.

Do you know how should such an 'enhanced' macro look like? Thanks for any suggestions.
Regards,

Mark





All times are GMT +1. The time now is 06:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com