View Full Version : Automated Printing
awald
11-01-2011, 02:10 PM
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.
JP2112
11-03-2011, 07:09 AM
Do you have any code written so far?
Charlize
11-04-2011, 08:03 AM
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
JP2112
11-04-2011, 09:56 AM
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.