ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening 4 files with 1 button? (https://www.excelbanter.com/excel-programming/318736-opening-4-files-1-button.html)

RustyR

Opening 4 files with 1 button?
 
Hi,

I have a boss who needs to open 4 files each week to print.
Is there a way I can give him an Excel page with a button on it which Prints
these 4 files?

Any help would be appreciated!!

Regards,
Rusty



Dick Kusleika[_4_]

Opening 4 files with 1 button?
 
Rusty

You could use a Workspace to open all four files at once. See under the
File menu - Save As Workspace.

If you want a macro that opens, prints, and closes the files, it might look
like this

Sub Open4Files()

Dim aFnames As Variant
Dim sPath As String
Dim i As Long
Dim wb As Workbook

aFnames = Array("File1.xls", "file2.xls", "file3.xls", "file4.xls")
sPath = "C:\MyFolder\"

For i = LBound(aFnames) To UBound(aFnames)
Set wb = Workbooks.Open(sPath & aFnames(i))
wb.Windows(1).SelectedSheets.PrintOut
wb.Close savechanges:=False
Next i

End Sub

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

RustyR wrote:
Hi,

I have a boss who needs to open 4 files each week to print.
Is there a way I can give him an Excel page with a button on it which
Prints these 4 files?

Any help would be appreciated!!

Regards,
Rusty




Ron de Bruin

Opening 4 files with 1 button?
 
Hi RustyR

Try this if the files are closed (There is no error check)
It will print 4 files in the C:\Data\ folder

Sub test()
Dim wbname As Variant
Dim N As Integer
Dim wb As Workbook
wbname = Array("test1.xls", "test2.xls", "test3.xls", "test4.xls")
For N = LBound(wbname) To UBound(wbname)
Set wb = Workbooks.Open("C:\Data\" & wbname(N))
wb.PrintOut
wb.Close False
Next
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"RustyR" wrote in message ...
Hi,

I have a boss who needs to open 4 files each week to print.
Is there a way I can give him an Excel page with a button on it which Prints
these 4 files?

Any help would be appreciated!!

Regards,
Rusty






All times are GMT +1. The time now is 10:50 PM.

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