Auto open, print, then close an excel file from in another?

stubs

New Member
Joined
Apr 5, 2006
Messages
41
I would like to have a file/small VB program to automatically open each Excel file (or Word file) in a specified folder, print its contents, then close the file...

Is it also possible to have it pick from a list of folder names, according to what day of the week it is?

For example, if I click on the file/program on a Wednesday, it would open all the files in the "Wednesday" folder, print them, and close them. No particular order is required.

I have started to try & figure this out myself, but would greatly appreciate any advice!



Thanks,
Stu
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

rjp

Board Regular
Joined
Jan 5, 2006
Messages
148
Try this:

Code:
Sub test()

    Dim fPath As String
    Dim fName As String

    Application.ScreenUpdating = False
    Application.EnableEvents = False

    'You'll need to customise the path in the next line
    fPath = "C:\" & Format(Date, "dddd") & "\"

    fName = Dir(fPath & "*.xls")

    Do While fName <> ""
        Workbooks.Open fPath & fName
        ActiveWorkbook.PrintOut
        ActiveWorkbook.Close

        fName = Dir
    Loop

    Application.ScreenUpdating = True
    Application.EnableEvents = True

End Sub
 

stubs

New Member
Joined
Apr 5, 2006
Messages
41
Cheers! I will give that a try... its much smaller than the code I was coiming up with! :oops:
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,969
Messages
5,856,590
Members
431,823
Latest member
irtezazaz

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
Top