PDA

View Full Version : [SOLVED] Printing Workbooks with certain criteria



bay_analyst
10-22-2004, 06:13 AM
I need to print off about 12 different workbooks from one of our network drives but only if they have been modified that day. I do this every Monday morning and need the entire workbooks printed (all sheets). Any suggestions?

Darlene

CBrine
10-22-2004, 06:23 AM
What your asking should be possible. Need some more information though.
Do you have anything specific that would ID them as Modified?
Do they all exist in the same folder?

Jacob Hilderbrand
10-22-2004, 02:15 PM
Try this:



Option Explicit

Sub OpenFiles()
Dim Path As String
Dim FileName As String
Dim Wkb As Workbook
Dim ModDate As Date
Application.EnableEvents = False
Path = "C:\" 'Change as needed
FileName = Dir(Path & "\*.xls", vbNormal)
Do Until FileName = ""
Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName)
ModDate = Wkb.BuiltinDocumentProperties("Last Save Time")
MsgBox ModDate
If ModDate > Date - 1 Then
'Print
Else
'No Print
End If
Wkb.Close False
FileName = Dir()
Loop
Application.EnableEvents = True
End Sub

If checking the date isn't precise enough you can use time as well. ModDate will have the date and time of the last modification for you to check against.

bay_analyst
10-25-2004, 05:09 AM
Thank You Jacob, works fine with a few modifications.

Darlene

Jacob Hilderbrand
10-25-2004, 05:42 AM
You're Welcome

Take Care