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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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
 
Upvote 0
Cheers! I will give that a try... its much smaller than the code I was coiming up with! :oops:
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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