Consulting

Results 1 to 5 of 5

Thread: Printing Workbooks with certain criteria

  1. #1
    VBAX Regular
    Joined
    Jul 2004
    Location
    Surrey, B.C.
    Posts
    8
    Location

    Printing Workbooks with certain criteria

    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

  2. #2
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    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?
    The most difficult errors to resolve are the one's you know you didn't make.


  3. #3
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    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.

  4. #4
    VBAX Regular
    Joined
    Jul 2004
    Location
    Surrey, B.C.
    Posts
    8
    Location
    Thank You Jacob, works fine with a few modifications.

    Darlene

  5. #5
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •