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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

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:
 

Watch MrExcel Video

Forum statistics

Threads
1,129,816
Messages
5,638,496
Members
417,029
Latest member
lingx86

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