Consulting

Results 1 to 4 of 4

Thread: Automated Printing

  1. #1

    Automated Printing

    Hi,

    I want to put together a script that will automatically print the newest file in a folder every morning. I can build this in Excel, but want to have it as an isolated VBS.

    Any thoughts?

    Thank you.

  2. #2
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    Do you have any code written so far?
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

  3. #3
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Option Explicit
    Dim objFSO, objFile, strFileProperties, colFiles, strFiles

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists("C:\Test\Document1.txt") Then
    Set objFile = objFSO.GetFile("C:\Test\Document1.txt")

    ' Display generel file properties
    strFileProperties = strFileProperties & "File name: " & objFile.Name & VbCrLf
    strFileProperties = strFileProperties & "File path: " & objFile.Path & VbCrLf
    strFileProperties = strFileProperties & "Folder placed on drive: " & objFile.Drive & VbCrLf
    strFileProperties = strFileProperties & "Date created: " & objFile.DateCreated & VbCrLf
    strFileProperties = strFileProperties & "Date last accessed: " & objFile.DateLastAccessed & VbCrLf
    strFileProperties = strFileProperties & "Date last modified: " & objFile.DateLastModified & VbCrLf
    strFileProperties = strFileProperties & "Parent folder: " & objFile.ParentFolder & VbCrLf
    strFileProperties = strFileProperties & "File size: " & objFile.Size & " bytes" & VbCrLf
    strFileProperties = strFileProperties & "File type: " & objFile.Type & VbCrLf
    MsgBox strFileProperties
    Else
    MsgBox "Selected file does not exist!"
    End If

  4. #4
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    In other words, loop through the folder and check either .DateCreated or .DateLastModified (or maybe both), then, depending on the filetype, print it. How do to that, depends on the particular filetype.
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

Posting Permissions

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