ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Print files in separate folders-please help (https://www.excelbanter.com/excel-programming/430618-print-files-separate-folders-please-help.html)

Ake

Print files in separate folders-please help
 

I have the following macro (i got from somewhere) that opens and prints the
excel files that i open in a common folder:

Public Sub PrintWorkbook()
Dim i As Integer
Dim FileNames As Variant
FileNames = Application.GetOpenFilename(, , "Choose workbooks", , True)
If IsArray(FileNames) Then
For i = 1 To UBound(FileNames)
Workbooks.Open FileNames(i)
ActiveWorkbook.ActiveSheet.PrintOut
ActiveWorkbook.Close (False)
Next i
End If
End Sub

What i want to do is open files that are located in different folders and
print them, what should i add to this program?


Bernie Deitrick

Print files in separate folders-please help
 

ake,

You can only select workbooks from one folder using the GetOpenFilename method, so you would either
need to run your macro once for each folder, or move all your files (or copies) into one folder.

HTH,
Bernie
MS Excel MVP


"ake" wrote in message
...
I have the following macro (i got from somewhere) that opens and prints the
excel files that i open in a common folder:

Public Sub PrintWorkbook()
Dim i As Integer
Dim FileNames As Variant
FileNames = Application.GetOpenFilename(, , "Choose workbooks", , True)
If IsArray(FileNames) Then
For i = 1 To UBound(FileNames)
Workbooks.Open FileNames(i)
ActiveWorkbook.ActiveSheet.PrintOut
ActiveWorkbook.Close (False)
Next i
End If
End Sub

What i want to do is open files that are located in different folders and
print them, what should i add to this program?





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

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