Please see the vbscript below. How can I modify this script so that it prints out documents in ascending order? I have 6 Word/Excel documents that need to print to comprise a packet so I would like them to print in order. I have each document prefixed with a # to sort, i.e. 1 - Documentation.docx ... 2 - FAQ.docx etc. Right now, it will just print in random order. My goal is to have each document print in the correct order for the number of copies requested since it is a packet.
Option Explicit
Dim NumberOfCopies
NumberOfCopies = GetNumberOfCopies()
PrintDocuments NumberOfCopies
Function EndsWith(textToTest, endText)
On Error Resume Next
Dim result
result = False
result = Rigth(textToTest, Len(endText)) = endText
EndsWith = result
End Function
Function GetNumberOfCopies()
On Error Resume Next
Dim inputText
Dim result
inputText = InputBox("Input the number of copies you would like")
result = 0
result = CLng(inputText)
GetNumberOfCopies = result
End Function
Sub PrintDocuments(numberOfCopies)
Dim currentNumberOfCopies
Dim currentPath
Dim files
Dim currentFile
Dim shApp
Dim shFolder
If numberOfCopies < 1 Then
Exit Sub
End If
Set shApp = CreateObject("Shell.Application")
currentPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
Set shFolder = shApp.NameSpace(currentPath)
Set files = shFolder.Items()
For Each currentFile in files
currentNumberOfCopies = numberOfCopies
Do While currentNumberOfCopies > 0
currentFile.InvokeVerbEx ("Print")
currentNumberOfCopies = currentNumberOfCopies - 1
WScript.Sleep 5000
Loop
Next
End Sub
Open in new window